Finding Beans

From RedBean

Jump to: navigation, search

Finding Beans

Finding Beans with RedBean is simple. To search for a bean with RedBeanPHP use the Finder. The Finder accepts plain old SQL and converts the results to beans. For instance if we want to get all the employees older than 60:

$seniors = R::find("employee", " age > 60 "); 
foreach($seniors as $senior) {
  echo $senior->name;
}

And here is another example:

$beans = R::find("book",
"title=? and author=? ",
array("Christine","Stephen King"));

To find just one bean use:

R::findOne("book", .. );
Personal tools