RedBean ORM和Codeigniter,如何使Fuse识别从CI默认模型路径加载的模型?

pun*_*bit 16 orm codeigniter

Codeigniter有自己的模型路径,模型从CI_Model扩展.我正在使用RedBean在Codeigniter中有一个库,将其加载到控制器上.在加载Rb之后,我尝试使用CI Loader来加载扩展redbean_simplemodel的模型(希望工作,没有错误),但模型中的事件/方法在bean上调用时没有任何效果.

例如,APPPATH/application/libraries/rb.php

class Rb {

    function __construct()
    {
        // Include database configuration
        include(APPPATH.'/config/database.php');

        // Get Redbean
        include(APPPATH.'/third_party/rb/rb.php');

        // Database data
        $host = $db[$active_group]['hostname'];
        $user = $db[$active_group]['username'];
        $pass = $db[$active_group]['password'];
        $db   = $db[$active_group]['database'];

        // Setup DB connection
        R::setup("mysql:host=$host;dbname=$db", $user, $pass);

    } //end __contruct()


} //end Rb
Run Code Online (Sandbox Code Playgroud)

然后在APPPATH/application/models/model_song.php上

class Model_song extends RedBean_SimpleModel {

 public function store() {
  if ( $this->title != 'test' ) {
  throw new Exception("Illegal title, not equal «test»!");
  }
 }

}
Run Code Online (Sandbox Code Playgroud)

在APPPATH/application/controllers/welcome.php上

class Welcome extends CI_Controller {

    public function index()
    {
        $this->load->library('rb');
        $this->load->model('model_song');

        $song = R::dispense('song');
        $song->title  = 'bluuuh';
        $song->track = 4;
        $id = R::store($song);
        echo $id;

    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何让RedBean(FUSE http://redbeanphp.com/#/Fuse)在Codeigniter上工作?

谢谢你的期待!

-----找到解决方案!

实际上,它正在运作!我试图在我的模型,方法存储()下面放置代码.那不行!我尝试放置一个名为update()的新方法,它确实有效!检查以下示例:

class Model_song extends RedBean_SimpleModel {

 public function update() {
  if ( $this->title != 'test' ) {
    throw new Exception("Illegal title!");
  }
 }

}
Run Code Online (Sandbox Code Playgroud)

解决方案如下:

"假设你已经在Codeigniter上安装了RedBean"

1)为«redbean»加载库2)使用ci_loader,加载所需的模型(模型必须扩展redbean_simplemodel)

谢谢你的期待!我希望这对其他人也有帮助.

pun*_*bit 3

解决方案如下:

\n\n

“假设您已经在 Codeigniter 上安装了 RedBean”

\n\n
    \n
  1. 加载 \xc2\xabredbean\xc2\xbb 的库
  2. \n
  3. 使用ci_loader,加载所需的模型(模型必须扩展redbean_simplemodel)
  4. \n
\n