7

I created a model called Model_base extending from ci_model and added all common functions inside it

class Model_base extends CI_Model {

function __construct()
{   
    parent::__construct();          
}
function create() {
    //do insert data into database
}

function read() {
    //do get data into database
}

function update() {
    //do update data into database
}

function delete() {
    //do delete data from database
}

}

Now I want to create a new model with extending base_model is it possible in CodeIgniter

hohner
  • 11,498
  • 8
  • 49
  • 84
  • possible duplicate of http://stackoverflow.com/questions/6569252/how-to-inherit-a-model-from-another-model-in-codeigniter – crafter Apr 25 '16 at 07:25

2 Answers2

2

Create a new model PHP file, and use:

class Model_New extends Model_Base {

   public function __construct()
   {
      parent::__construct();
   }

}
hohner
  • 11,498
  • 8
  • 49
  • 84
0

Yes, you can, just remember to call the parent::__construct(); in the constructor of your new Model.

Hieu Le
  • 8,288
  • 1
  • 34
  • 55