change array index while query

hi there

by default after a query like below, the result is a array with index 0,1,…




$query = new Query;

      $query->select('*')->from('item')->where("id IN ($items_id)");

      $result = $query->all();



i want to change array index to be item’s table id field

is it possible?

http://www.yiiframework.com/forum/index.php/topic/59958-تغییر-اندیس-آرایه-هنگام-کوئری/page__pid__268177#entry268177

Use indexBy() in your query to have the primary key of the field be its index.

something like this?




 $query->select('*')->from('item')->where("id IN ($items_id)")->indexBy('id');