$cats = Cats::find()
->select(['_id', 'name'])
//->indexBy('_id')
->asarray()
->all();
$cats = Cats::find()
->select(['_id', 'name'])
->indexBy('_id')
->asarray()
->all();
Illegal offset type
function IndexBy_Id($array) {
foreach ($array as $item) {
$array2[(string) $item['_id']] = $item;
}
return $array2;
}