7

我在 MySQL 数据库中有 2 个表,我使用的是学说 1.2 和 symfony 1.4.4

安装基础和备件

Installedbase:
ib_id
app_id
location

Spare:
spare_id
app_id
amount

现在我想加入表以显示备用应用程序中有多少。

例如

$q = self::createQuery("l")
->select('i.*, s.*')
->from('InstalledBase i, Spare s')
->execute();

return $q;

Doctrine 知道 app_id 字段上的表之间存在关系,但我得到了错误

500 | Internal Server Error | Doctrine_Hydrator_Exception 
"Spare" with an alias of "s" in your query does not reference the parent component it is related to.

yaml: http://pastey.net/137237 我无法弄清楚这一点,有人知道什么教义在抱怨吗?

4

2 回答 2

4
->from('InstalledBase i, i.Spare s')

...查询中别名为“s”的“备用”不引用与其相关的父组件。

请向此查询添加一些进一步的条件,不要从两个表中返回所有内容。

于 2010-06-04T09:02:10.390 回答
0

从表面上看,您并没有告诉 Doctrine 这两张表是相关的。

于 2010-06-04T07:56:57.583 回答