0

i'm using redbeanphp like this

$r = R::find('chat', 'room_id = ? AND time > ? ORDER BY time ASC', array($w->id, $_POST['latest_timestamp']));

Now i a have a list of bean objects inside $r so is there any way to access rows without convert it to array?

(i know i can't use it with foreach !)

ms000
  • 1
  • 1

1 Answers1

0

According to the documentation here http://redbeanphp.com/manual3_0/finding_beans

R::find is to load a single entry, shouldn't you be using R:findAll to get an array collection that you can iterate via foreach?

i.e.

$r = R::findAll('chat', 'room_id = ? AND time > ? ORDER BY time ASC', array($w->id, $_POST['latest_timestamp']));

foreach ($r as $myItem)
{
    // do something with $myItem
}
Latheesan
  • 23,247
  • 32
  • 107
  • 201