php - specify key values for return $query->fetchArray()? -
using doctrine, i'm doing query kinda this:
$query = doctrine_query::create()->select('id,name')->from('people'); return $query->fetcharray();
it returns object similar 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 array's keys count 0, 1, 2, etc? question: possible specify want key values come from? example, key values in above case 34, 156 , 27.
i noticed in doctrine doc's both fetcharray()
has parameters can feed them, doesn't parameters are...
public array fetcharray(string params)
http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_query.html#fetcharray()
also, can repopulate new array prefered key/value combinations, i'm trying avoid processing required.
check out indexby dql keyword.
try like:
<?php $query = doctrine_query::create() ->select('p.id,p.name') ->from('people p indexby p.id');
Comments
Post a Comment