我想在库db
中自定义一些东西…
我在application/core文件夹中创建了核心系统类MY_DB
:
class MY_DB extends CI_DB {
public function __construct() {
$CI =& get_instance();
$CI->load->database();
$this->db = $CI->db;
}
public function get($table = '', $limit = NULL, $offset = NULL) {
// my code custom...
$this->db->get($table, $limit, $offset);
}
public function insert($table = '', $set = NULL) {
// my code custom...
$this->db->insert($table, $set);
}
}
但显然它不起作用
我想当我执行$this->db->get()
时,它将运行我在MY_DB
类中定制的代码。
如果你能看看我的问题,分享一点你的科学知识,我将非常感激。谢谢!
CodeIgniter(目前是最新版本3.0.0)不支持像对其他库那样扩展其数据库类。当然,这不是不可能的,但是没有官方的、内置到框架中的方法来做到这一点,您必须自己想办法。