Lets say I have a super simple table of items:
Table: Items
-
item_id
-
item_name
Then I want to find a specific item (ex: item_id=58234) in the array of models that is the result of this:
$items=Items::model()->findAll($criteria);
Is there a convenient way (like a "yii way") to this? …I mean, except for the obvious:
foreach ($items as $i => $item) {
if ($item->item_id == 58234) {
break;
}
}
// $items[$i] holds the model I want
I might also ask another question like: Is there a way to make findAll use an attribute for indexing in the array it returns? (then my task would be super easy)
…hm, come to think of it, I don’t think that last question is gonna have yes for an answer, but wouldn’t that be a cool feature? Qiang?