Model & Library autoload for CodeIgniter
$this->load->library('aladdin');
$this->load->library('giant');
$this->load->model('student');
$this->load->model('teacher');
...
$this->load->model('blablabla');
// then we begin to work
$this->aladdin->summon('Arab God');
$this->giant->breakTheWall('Rose');
$this->student->playGame('lol');
$this->teacher->teach();
// Start working at the beginning
$this->aladdin->summon('Arab God');
$this->giant->breakTheWall('Rose');
$this->student_model->playGame('lol');
$this->teacher_model->teach();
Just copy application/core/MY_Controller.php
to your same CI directory, that's it.
$this->aladdin->summonXXX();
means:
$this->load->library('aladdin');
$this->aladdin->summonXXX();
with dash string:
$this->myth_aladdin->summonXXX();
means:
$this->load->library('myth/aladdin');
$this->myth_aladdin->summonXXX();
$this->student_model->playXXX();
means:
$this->load->model('student_model');
$this->student_model->playXXX();
with dash string:
$this->school_student_model->playLOL();
means:
$this->load->model('school/student_model');
$this->school_student_model->playLOL();
// now you can call them without $this->load->database();
$this->db->query();
$this->db_read->query();
$this->db_write->query();
have fun :)