所以我有两张桌子:X和Y。
schema.yml如下所示:
X:
columns:
something: { type: string(255), notnull: true }
y_id: { type: integer, notnull: true }
relations:
Y: { onDelete: CASCADE, local: y_id, foreign: id, foreignAlias: xs }
Y:
columns:
something: { type: string(255), notnull: true }
在我的表格里我有:
class XTable extends Doctrine_Table
{
function getXesWithYs()
{
return $this->createQuery("x")->leftJoin("x.Y y")->execute();
}
}
生成的查询实际上同时选择了x.*和y.*,但是当我尝试使用y的数据时,它会对从y中选择的每一行执行额外的查询,其中y.id=x.y\u id。
所以如果我这么做了:
echo $results[0]->Y->something;
$result[1]
是的,我得到另一个查询。