>我已经使用查询生成器构建了一个正确的工作查询。
但是现在,有一个条件,即方法(负责将某些表动态添加到查询)必须向查询添加列。
我尝试了以下方法(它要复杂得多,但几乎相同):
$querybuilder->select('EntityA.Property')
->from ('EntityA');
// here is happening some awesome stuff... ;-)
// Now i have to add the Table, and The column
$querybuilder->innerJoin('EntityB'); // this is working
$querybuilder->add('select', 'EntityB.Property'); // overwrites my columnlist
// $querybuilder->select('EntityB.Property'); // also overwrites my columnlist
提前致谢
为什么不像这样单独组装选择子句:
$fields = array();
$fields[] = "EntityA.Property"
// code here, and finally, you decide you need EntityB
$fields[] = "EntityB.Property"
$querybuilder->innerJoin('EntityB');
// done with building the query, assign select
$querybuilder->select($fields);