I’m using readbeanphp as ORM for my php project. I’m trying to load a bean with an additional where clasue. But i’m not sure how to do this.
Normally i’d get a ‘bean’ like this:
$book = R::load('book', $id);
Which is basically like saying:
SELECT * FROM book WHERE id = '$id'
But i need to add another condition in the where clause:
SELECT * FROM book WHERE id = '$id' AND active = 1
How can i do this with redbeanphp?
RedBean_Facade::loadis using for primary key only.if you want get beans by a complex query
use
R::findlike,Read more about R::find
http://www.redbeanphp.com/manual/finding_beans
try to use getAll to write your query directly with parameters
Read more about queries,
http://www.redbeanphp.com/manual/queries