【问题标题】:Get redbean instance获取红豆实例
【发布时间】:2013-07-10 12:00:24
【问题描述】:

我需要获取 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 ...

我可以看到方法在那里。我怎么能做到这一点?

【问题讨论】:

    标签: php orm redbean


    【解决方案1】:

    我在稍微挖掘源代码后找到了解决方案。可以通过以下方式获取。它接缝应该将其添加到 RedBean 文档中。

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-18
        • 2013-04-24
        • 1970-01-01
        • 1970-01-01
        • 2022-11-23
        相关资源
        最近更新 更多