I have two entities in many to many relation:
class Foo
{
/**
* @ORM\ManyToMany(targetEntity="Bar", inversedBy="foos")
* @ORM\JoinTable(name="Foo_x_Bar")
*/
protected $bars;
}
class Bar
{
/**
* @ORM\ManyToMany(targetEntity="Foo", mappedBy="bars")
*/
protected $foos;
}
I would like to fetch all pairs of Foo and Bar instances in a result set ie:
array (size=2)
0 =>
array (size=2)
'Foo' => Foo instance
'Bar' => Bar instance
1 =>
array (size=2)
'Foo' => Foo instance
'Bar' => Bar instance
I tried to do it in a several ways described on the web but I still can't select the whole entities. I am able to get particular columns with this query:
SELECT f.something, b.somethingElse FROM Entity\Foo f LEFT JOIN f.bars b
but when I omit column names in SELECT statement I only get Foo instances and Bar instances disappears. How can I get a result set containing both entities?