I've noticed a behaviour I've not really encountered with doctrine under symfony 3.3 of late.
If I use a querybuilder with some joins, in the result set that I get back, I end up with each table on a new row in the resultant array - For example, if I join t1 and t2 onto t3, where each is a doctrine entity, I will get back a result that looks a little like this:
$results[0] => (row1 entity for t3)
$results[1] => (row1 entity for t1)
$results[2] => (row1 entity for t2)
$results[3] => (row2 entity for t3)
$results[4] => (row2 entity for t1)
$results[5] => (row2 entity for t2)
These 3 array items correspond to each of the entities / 'tables' that make up a single joined 'row' of the result set.
I've found that HYDRATE_SCALAR gives me a more traditional 'scalar' (duh.. no shock there) result where each element of the result array contains one complete, scalar row.. but then I don't get nice hydrated entity objects to work with :(
I'm wondering, is there any way using symfony / doctrine natively without writing my own helper method(s) that I can get a result array where each element corresponds to a single row in the result set? perhaps with keys for each of the above entity objects?
Or, aside from that, how do people usually work with this? Is it 'safe' to iterate such a result set and handle each set of 3 array elements in the above example as one 'row'? Ie, chunk the array into 3's, or iterate 3 at a time?
This behaviour really surprised me and seems quite unintuitive. Any education here as to what the thinking behind this is would likely help too.
Also, when I use HYDRATE_ARRAY, this does not seem to hydrate related entities in any OneToOne, OneToMany, or ManyToOne relationships that I have defines. I'd expect a multidimensional array containing my related entity properties.. wishful thinking, or can this be achieved (again without additional helper methods)
Thanks all!
*Edit - mistake in my example