I faced with problem while fetching query results, my code:
$result = $query->execute(); $array1 = $result->fetchAllKeyed(1, 0); $array2 = $result->fetchAllKeyed(2, 0);
But the $array2
is empty, so fetchAllKeyed
cut all values from $result
.
I’m already tried to use the following:
$query2 = clone $query; $result = $query->execute(); $result2 = $query2->execute(); $array1 = $result->fetchAllKeyed(1, 0); $array2 = $result2->fetchAllKeyed(2, 0);
It’s works, but I don’t want do two queries instead of one.
So, how can I do two (or more) different “fetch” from one result?
Sponsored by SupremePR