How to Inherit A Model from Another Model in CodeIgniter How to Inherit A Model from Another Model in CodeIgniter codeigniter codeigniter

How to Inherit A Model from Another Model in CodeIgniter


core/MY_Model is good if there's only 1 important superclass for your models.

If you want to inherit from more than model superclass, a better option is to change your autoload configuration.

In application/config/autoload.php, add this line:

    $autoload['model'] = array('genesis_model');


Put the file genesis_model.php in the core directory


Change your Human_model to this:

include('genesis_model.php');class Human_model extends Genesis_model {    function __construct() {        parent::__construct();    }    function get_human() {        return parent::get();    }}

notice the get_human function and the include.