Extract specific bean from array of beans obtained using Find in RedBean ORM

18 views
Skip to first unread message

attitude_is_altitude

unread,
May 2, 2015, 5:47:24 AM5/2/15
to redbe...@googlegroups.com

Let's say I do this:

$results=R::find('markers', ' age = ? ', array($age));

Now, $results will be an array of beans.

If I want only one bean (instead of an array), and want $results to be a bean, I can use findoneinstead of find.

If I want to loop through each bean in array and see some property, I could do something like this:

foreach($results as $row){
    echo $row->id;
}


My question:

Is there some way to directly reference (say) the 3rd bean in the $results array?

Note: The keys in the $results array are based on the id of each bean. So, even though $results may have a size of 3 (or more), doing $results[2] will only produce a bean if there's a bean in there with an id of 2, and it will not necessarily be the 3rd bean in the array.

gabor

unread,
May 2, 2015, 5:52:52 AM5/2/15
to redbe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages