Reputation: 91193
Using Doctrine, I'm doing a query kinda like this:
$query = Doctrine_Query::create()->select('id,name')->from('people');
return $query->fetchArray();
It returns an object similar to the following array of arrays:
array(3) {
[0]=>
array(4) {
["id"]=>
string(1) "34"
["name"]=>
string(7) "John"
}
[1]=>
array(4) {
["id"]=>
string(1) "156"
["name"]=>
string(6) "Bob"
}
[2]=>
array(4) {
["id"]=>
string(1) "27"
["name"]=>
string(7) "Alex"
}
}
Notice how the array's keys count up from 0, 1, 2, etc? My question: Is it possible to specify where you want the key values to come from? For example, I would like the key values in the above case to be 34, 156 and then 27.
I noticed in the Doctrine doc's that both fetchArray()
has parameters that you can feed them, but it doesn't say anything about what those parameters are...
public array fetchArray(string params)
http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_query.html#fetchArray()
Also, I can obviously just repopulate a new array with the prefered key/value combinations, but I'm trying to avoid the extra processing required.
Upvotes: 1
Views: 2776