A
A
Albert Tobacco2015-06-25 11:50:57
Yii
Albert Tobacco, 2015-06-25 11:50:57

A query returning an array of ActiveRecord indexed by the primary key of the ActiveRecord (or better by the specified parameter)?

A query that returns an array of ActiveRecord indexed by the primary key of ActiveRecord (or rather, by the specified parameter) ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
corpsepk, 2015-06-25
@bighoc

CDbCriteria index property if you are talking about
www.yiiframework.com/doc/api/1.1/CDbCriteria#index...
*Or indexBy if you are talking about yii2

// return all customers in an array indexed by customer IDs
// SELECT * FROM `customer`
$customers = Customer::find()
    ->indexBy('id')
    ->all();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question