CodeIgniter Forums
Inheritance of database methods (active record) by model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Inheritance of database methods (active record) by model (/showthread.php?tid=3519)



Inheritance of database methods (active record) by model - El Forum - 10-07-2007

[eluser]jahshuah[/eluser]
Is there any way for a model to inherit the default active record methods? For example, I have a model named blog_model that looks like this:
Code:
class Blog_model extends Model
{
    function Blog_model()
    {
        parent::Model();
    }
}
I know that I can define my own custom methods, however, I would like the model to also have access to things like:
Code:
$this->db->get() // would be $this->blog_model->get()
$this->db->getwhere() // would be $this->blog_model->getwhere()
$this->db->select()  // would be $this->blog_model->select()
$this->db->from() // would be $this->blog_model->from()
...etc...
Is there any way to do this without explicitly defining those functions in my model?

Thanks in advance.