I have multiple models which all have the same functions in my framework. I decided to create one "parent" model and all of my other models would extend and inherit its functions like this.
My other models would be like this:
class Games_model extends MY_Model {
protected $table = 'games';
protected $_default_select = array();
protected $_default_join = array();
public function __construct() {
$this->_default_select = array(
$this->table.'.*',
$this->table.'.id as id',
$this->table.'.name as name',
'categories.id as cat_id',
'categories.name AS cat_name'
);
$this->_default_join = array('categories', 'categories.id = fiches.console_id', 'left');
}
}
Here's how I use it:
$this->games_model->limit(30,0)->where(array('categorie_id' => 1))->get_list()->result();
Is it a better idea to do like that or to have all the code of MY_Model
in Games_model
?