UserNaN
UserNaN

Reputation: 137

How to custom library DB using Codeigniter

I want custom a few things in the library db...

And I created core system classes MY_DB in application/core folder:

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);
    }
}

but apparently it does not work.

I want when I execute $this->db->get(), it will run the code I customized within class MY_DB.

If you just take a look at my problem and share a bit of your science, I'd be very grateful. Thanks!

Upvotes: 0

Views: 362

Answers (1)

Narf
Narf

Reputation: 14752

CodeIgniter (at this time, latest version 3.0.0) doesn't support extending its database classes like it does with other libraries. It's not impossible of course, but there's no official, built-into the framework way to do it and you'll have to come up with your own hack for it.

Upvotes: 1

Related Questions