联接表的列缺失

时间:2018-08-15 16:07:01

标签: zend-framework zend-db zend-framework3 zend-db-select

我缺少联接表的列。我有两个表,如:

t_q_filialen 1-> n t_mandant

我在模型中做了如下选择语句:

    $select= new Select ();         //another try ('t_mandant','t_q_filialen');
    $select->columns(['id', 'cccid' ,'geschid', 'name', 'langname','filiale']);
    $select->from('t_mandant');
    $select->join('t_q_filialen', 't_q_filialen.id=t_mandant.geschid ', [ 'filialeid'=>'id','filiale'=>'name']);   

我希望在我的视图脚本中获得具有给定别名'filiale'的列名:

$this->escapeHtml($mandant->filiale);

我得到一个错误。

  

“字段列表”中的未知列“ t_mandant.filiale”

如果我改回到表t_mandant中的外键列“ geschid”,然后尝试:

var_dump(get_object_vars($mandant));

表“ t_q_filialen”中的列不在集合中。

怎么了?

我有一个小主意,说我可以成为分页专家。我像这样实例化分页器:

$resultSetprototype=new ResultSet();
$resultSetprototype->setArrayObjectPrototype(new Mandant());
$paginatorAdapter= new DbSelect($select, $this->tableGateway->getAdapter(), $resultSetprototype);
$paginator=new Paginator($paginatorAdapter);
return $paginator;

如何更改此设置,以便接受我的加入?可能与此有关:

$resultSetprototype->setArrayObjectPrototype(new Mandant());

在没有分页功能的其他模型中,我使用了它,并且可以使用:

$rowset = $this->tableGateway->adapter->query($statment, "execute");

那可能是解决方案?我确实更希望最后一种可能性,但是我不知道如何与分页器结合使用。 任何帮助表示赞赏!

我列出了几个想法,但我的目标是使集合中的两个表的列都带有分页器对象。

1 个答案:

答案 0 :(得分:0)

我的天哪,我刚刚尝试过:

$paginatorAdapter= new DbSelect($select, $this->tableGateway->getAdapter());

没有结果集原型

相关问题