phpactiverecordredbean

RedBeanPHP: find all books where property is null?


I tried this, but I dont get any results:

$Books= R::findAll( 'books' , ' WHERE accepted IS NULL ORDER BY update_time DESC LIMIT 100 ' );

What should I do?

EDIT:

My PHP:

            $requests = array();

            $Books = R::findAll( 'books' , ' ORDER BY update_time DESC LIMIT 100 ' );

            foreach ($Books as &$value) {
                $request = new stdClass();
                $request->name= $value->name;     
                $request->accepted = $value->accepted;                  
                $request->id = $value->id;                    
                $requests[] = $request;
            }

            print_r(json_encode((object)$requests));

In Javascript I do a console.log(object); and i get this:

Object
  0: Object
     name: "Mem û Zîn"
     accepted: null
     id: "1"
  1: Object
      ... 

With the "WHERE" statement and R::findAll I get nothing.

EDIT: OK thx to @gbelisario this works:

$Books = R::getAll( 'select * from books WHERE accepted IS NULL ORDER BY update_time DESC LIMIT 100 ' ); 

            foreach ($Books as &$value) {
                $requests[] = $value;
            }


            print_r(json_encode((object)$requests));

Solution

  • Have you tried this?

    R::getAll( 'select * from books WHERE accepted IS NULL ORDER BY update_time DESC LIMIT 100 ' );