So I have two tables: X and Y.
The schema.yml looks like:
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 }
And in my XTable I have:
class XTable extends Doctrine_Table
{
function getXesWithYs()
{
return $this->createQuery("x")->leftJoin("x.Y y")->execute();
}
}
The generated query does in fact select both x.* and y.*, but when I try using Y's data, it performs an extra query for every row selecting from Y where y.id = x.y_id.
So if I do:
echo $results[0]->Y->something;
Doctrine will run an extra query fetching Y's data again.
This only happens once per Y row. If I use it again it won't load it a 3rd time, but if I use $result[1]
's Y, I get another query.