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 findone
instead 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;
}
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.