How to store a (boxed) model to the database?

22 views
Skip to first unread message

Magnus W

unread,
Feb 8, 2017, 2:42:30 PM2/8/17
to redbeanphp
I had expected the code below to store the model data to the database, but all it does is insert a new empty row.

class Model_Comment extends RedBean_SimpleModel {
 
public $message;
 
public $something;
}

R
::setup('sqlite:../data/slask.db');
R
::nuke();

$b
= R::dispense('comment');
$m
= $b->box();
$m
->message = 'Test';
R
::store($m);





What am I doing wrong, and how can I get a boxed model to be stored? Even trying to store 

$m->unbox()

wont work

Magnus W

unread,
Feb 8, 2017, 2:42:30 PM2/8/17
to redbeanphp
If I run the below code, I'd expect that the model would get stored in the database, but it just inserts an empty row without the message.


class Model_Comment extends RedBean_SimpleModel {
    public $message;
    public $something;
}

R::setup('sqlite:test.db');
R::nuke();

$b = R::dispense('comment');
$m = $b->box();
$m->message = 'Test';
R::store($m);


How can I get RedBean to insert data from a Model instead of a Bean?

Even using 

\R::store($m);

won't work...

Reply all
Reply to author
Forward
0 new messages