Welcome Guest, Not a member yet? Register   Sign In
Extending the default model
#14

[eluser]m4rw3r[/eluser]
Personally I don't extend or USE the default model (with IgnitedRecord).
Instead I add this:
Code:
class Amodel{
    function Amodel(){
        // just fetch the database instance
        $CI =& get_instance();
        $this->db =& $CI->db;
    }
    /**
     * To fool CI, letting it think this is a proper model.
     */
    function _assign_libraries(){}
}
The reason I do this is that I only use the db object, and I think it is better to restrict interaction with the controller object (and print_r becomes a mess).

This with extending CI's Model class, I think it can be done somewhat nicely like this:
CI_Model class in system/libraries/Model.php
MY_Model class in app/libraries/MY_Model.php
either conditional require of a class named Model which extends one of those above (depends on if MY_Model exists), or like in the db class, conditional eval of such a class.


Messages In This Thread
Extending the default model - by El Forum - 06-11-2008, 03:02 AM
Extending the default model - by El Forum - 06-11-2008, 04:47 AM
Extending the default model - by El Forum - 06-19-2008, 09:06 AM
Extending the default model - by El Forum - 06-21-2008, 03:50 AM
Extending the default model - by El Forum - 06-21-2008, 04:48 AM
Extending the default model - by El Forum - 07-09-2008, 03:36 PM
Extending the default model - by El Forum - 07-09-2008, 03:49 PM
Extending the default model - by El Forum - 07-09-2008, 03:55 PM
Extending the default model - by El Forum - 08-14-2008, 01:29 PM
Extending the default model - by El Forum - 08-14-2008, 02:54 PM
Extending the default model - by El Forum - 08-14-2008, 03:00 PM
Extending the default model - by El Forum - 08-15-2008, 05:17 AM
Extending the default model - by El Forum - 08-15-2008, 12:25 PM
Extending the default model - by El Forum - 08-15-2008, 01:16 PM
Extending the default model - by El Forum - 12-18-2008, 11:32 PM
Extending the default model - by El Forum - 12-19-2008, 02:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB