我需要获取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 ...我可以看到方法就在那里。我怎么才能做到这一点呢?
发布于 2013-07-10 20:07:43
经过对源码的挖掘,我找到了解决方案。它可以通过以下方式获得。看起来这应该被添加到RedBean文档中。
R::setup('mysql:host=localhost;dbname=t2odemo','root','');
$toolbox = R::$toolbox;
$redbean = $toolbox->getRedBean();发布于 2016-08-08 13:26:43
如果有人仍在尝试获取redBean实例,这对我(版本4.3.2)有效:
R::setup(...credentials stuff);
$redBean = R::getToolBox();
$rbInstance = $redBean->getDatabaseAdapter();https://stackoverflow.com/questions/17570122
复制相似问题