I am trying to get a simple nested bean connection - what am I missing?
I really like the simple ORM syntax in redbean and really want to use it, but I can't get it to work for me!
Is there anything else similar that might be a little more mature? I want something lightweight and simple to create wordpress plugins, but you need to know that I can rely on it in the future ...
I am only starting to think about using ezsql / sqlite, but rather I wonβt: /
Thanks for any help ...
function p($s){ $s = htmlentities(print_r($s,true)); echo "<pre>$s</pre>"; } require('rb.php'); R::setup('sqlite:dbfile.sql'); //sqlite\ R::debug(true); // R::wipe('book'); // R::wipe('author'); $book = R::dispense( 'book' ); $book->title = 'Boost development with RedBeanPHP'; $a = R::dispense('author'); $a->name = "Dave"; $book->author = $a; list($page1,$page2) = R::dispense('page',2); $book->pages = array($page1,$page2); $id = R::store($book); echo $b = R::load('book',$id); echo $b->author->name;
When I try to save the pages, I get the following error.
Fatal error: Throw a "RedBean_Exception_Security" exception with message 'Invalid Bean: Property pages in /Users/sig/Sites/redbean/rb.php:1508 Stack trace: # 0 /Users/sig/Sites/redbean/rb.php ( 1587): RedBean_OODB-> check (Object (RedBean_OODBBean)) # 1 /Users/sig/Sites/redbean/rb.php(2523): RedBean_OODB-> store (Object (RedBean_OODBBean)) # 2 / Users / sig / Sites / redbean / index.php (30): RedBean_Facade :: store (Object (RedBean_OODBBean)) # 3 {main} selected /Users/sig/Sites/redbean/rb.php on line 1508
source share