【问题标题】:codeigniter extend database driver call to undefined method my_db_mysql_driver::select()codeigniter 将数据库驱动程序调用扩展到未定义的方法 my_db_mysql_driver::select()
【发布时间】:2015-01-10 04:26:21
【问题描述】:
在 codeigniter 中,我需要一个可以对 where 子句进行分组的自定义活动记录类。偶然发现this 和一个关于如何extend the mysql driver 的教程。这样做后,我收到一个错误 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();
【问题讨论】:
标签:
php
mysql
database
codeigniter
【解决方案1】:
您的自定义活动记录类必须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();
}
}