【发布时间】:2018-02-22 10:01:09
【问题描述】:
我在 symfony 3.4 项目中使用 pomm。这是我的用例。
在从 Pomm 命令生成的模型中,我实现了这个方法:
$sql = <<<SQL
select tableA.*, array_agg(tableB) as tableB
from tableA, tableA_tableB, tableA
where tableA.id=$id and tableA.id=tableA_tableB.tableA_id and tableB.id=tableA_tableB.tableB_id
group by tableA.id
SQL;
$projection = $this->createProjection()
->setField('tableB', 'tableB', TableB::class)
;
return $this->query($sql, [], $projection);
我有一个表 A 和表 B。 tableA 可以有 0 到 N 个 tableB,tableB 可以有 0 到 N 个 tableA。我的问题是我无法在投影的“tableB”字段中获取 tableB 的集合。 Table::class 是一个灵活的实体。我应该怎么办 ?谢谢!
【问题讨论】:
标签: php symfony many-to-many projection pomm