Codeigniter 将数据库驱动程序调用扩展到未定义的方法 my_db_mysql_driver::select()


codeigniter extend database driver call to undefined method my_db_mysql_driver::select()

在codeigniter中,我需要一个自定义的活动记录类,它可以对where子句进行分组。偶然发现我找到了这个以及如何扩展 mysql 驱动程序的教程。这样做后,我收到错误 Fatal error: Call to undefined method MY_DB_mysql_driver::select() .我已经按照教程中说明的步骤进行操作,但仍然没有运气。

这是我的sql语句:

$this->db->select('post_id, post_title');
$this->db->from('articles');
$this->db->where($sqlParams);
$this->db->open_bracket();
$this->db->or_like($sqlLikeParams);
$this->db->close_bracket();

您的自定义活动记录类必须extends CI_Model

class Active_record extends CI_Model {
  function __construct()
  {
    parent::__construct();
  }

  function your_function() { 
   /* Your code here*/
    $this->db->select('post_id, post_title');
    $this->db->from('articles');
    $this->db->where($sqlParams);
    $this->db->open_bracket();
    $this->db->or_like($sqlLikeParams);
    $this->db->close_bracket();
  }
}