On Saturday, September 22, 2012 2:44:37 PM UTC+2, gonzo wrote:
> I have a DQL that is executed multiple times with different parameters.
> On the second (and subsequent) run, there is a difference between the
> results returned by getArrayResult() and execute() - it seems that there is
> some kind of caching in place so that the result of execute is the same
> every time (despite the parameters being different).
> I have checked that the caching part of AbstractQuery:execute is not
> matched (e.g.
> https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Ab...)
> does not hit.
> Can anyone explain?
> The code I've used to demonstrate the issue is:
>> foreach($q->getArrayResult() as $group) {
>> foreach($group['properties'] as $property) {
>> foreach($property['values'] as $value) {
>> echo $value['id'] . ' ';
>> }
>> }
>> }
>> echo '<br>';
>>> foreach($q->execute() as $group) {
>> foreach($group->getProperties() as $property) {
>> foreach($property->getValues() as $value) {
>> echo $value->getId() . ' ';
>> }
>> }
>> }
>> echo '<br><br>';
> That displays e.g. the following:
>> 51 52 137 55
>> 51 52 137 55
>>> 73 74 141 177 77
>> 51 52 137 55
>>> 78 79 142 178 82
>> 51 52 137 55
>>> 83 84 143 179 87
>> 51 52 137 55
> As you see the second line of each segment remains the same, whereas the
> first line (array hydration) is correct.
> Thanks in advance :)