获取redbean实例

时间:2013-07-10 12:00:24

标签: php orm redbean

我需要获取redbean instacne并将其传递给我需要的模型函数。 This document说了一种做法。

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

但这不起作用。它给了我错误

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

我可以看到方法就在那里。我怎么能得到这个?

2 个答案:

答案 0 :(得分:2)

我在挖掘源头后找到了解决方案。它可以通过以下方式获得。它接缝应该添加到RedBean文档中。

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

答案 1 :(得分:0)

如果还有人试图获取redBean个实例, 这对我有用(版本4.3.2):

R::setup(...credentials stuff);
$redBean = R::getToolBox();
$rbInstance = $redBean->getDatabaseAdapter();