Reputation: 4053
I want to do self join between A
and well A
.
It works as long as I do not try to select fields from joined self.
So:
SELECT a.id
FROM A AS a
LEFT JOIN A AS a2;
Will work (or at least throw no exceptions/errors).
While:
SELECT a.id, a2.id AS a2_id
FROM A AS a
LEFT JOIN A AS a2;
Will not work, as Doctrine require proper ResultSetMapping for it. Whicch require join column by which join is executed.
But there is non to provide. Its every record with every record join. No conditions attached ;)
So is it possible? Has doctrine have some special syntax for it?
Upvotes: 1
Views: 134
Reputation: 4053
Got illuminated seconds after clicking that "Post Your Question" button.
Here it goes (will work with second SELECT
from question):
$rsm->addEntityResult('A', 'a');
$rsm->addFieldResult('a', 'id', 'id');
$rsm->addEntityResult('A', 'a2');
$rsm->addFieldResult('a2', 'a2_id', 'id');
Yes. Just repeat addEntityResult
with proper aliasing.
Upvotes: 0