Search code examples
phpormredbean

Get redbean instance


I need to get the redbean instacne and pass it to the model functions that I need to. This document says a way of doing it.

$toolbox = RedBean_Setup::kickstart('mysql:host=localhost;dbname=demo','root','');
$redbean = $toolbox->getRedBean();

But it dose not work. It gives me error

Fatal error: Call to a member function getRedBean() on a non-object in ...

I can see the method is there. How could I achive this ?


Solution

  • I found the solution after little digging of source. It can be get in following way. It seams this should be added to the RedBean document.

    R::setup('mysql:host=localhost;dbname=t2odemo','root','');
    $toolbox = R::$toolbox;
    $redbean = $toolbox->getRedBean();