zend-framework - 连接表的列丢失
问题描述
我缺少连接表的列。我有两张桌子,例如:
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”
如果我改回 'geschid' 这是表 t_mandant 中的外键列并尝试:
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");
那么这可能是解决方案吗?我真的更喜欢最后一种可能性,但我不知道如何将它与分页器结合使用。任何帮助表示赞赏!
我列出了几个想法,但我的目标是让我的集合中的两个表的列都带有分页器对象。
解决方案
天哪,我刚试过:
$paginatorAdapter= new DbSelect($select, $this->tableGateway->getAdapter());
没有结果集原型
推荐阅读
- android - 为什么我的 RecyclerView 没有显示在 Fragment 中?
- unity3d - 如何在 Unity 中点亮 3D 对象的所有面
- bash - Bash script - user input 'not an identifier:'
- exception - 如何在raise语句后使python脚本继续
- c - amqp 上的 C 二进制消息
- javascript - Angular:单元测试 - 无法测试三元分支的代码覆盖率
- javascript - 如何在快递路线之间传递变量?
- anaconda - 为什么在 anaconda/lib 中存在大小相同但名称略有不同的重复/三重文件夹?
- common-lisp - 如何在 common lisp 中编写 multf 函数
- typescript - 为什么这个 JSON 属性被记录为未定义?