codeigniter seems not reusing model object -


typically, codeigniter uses below structrue.

class acontroller extends ci_controller {     public function __construct()     {         parent::__construct();         $this->load->model('modela');         $this->load->model('modelb');         $this->load->model('modelc');         ...     } } 

and i'm new in codeigniter, i'm wondering if can make more fast. should load these models whenever being made each request? causes slow response.

in case of python tornado, can store database model object request share 1 model object. there method in codeigniter?

you need make sure model loaded before using it.

1.you can write inside controllers construct function don't need load model inside other method.as example

class acontroller extends ci_controller {    public function __construct()     {         parent::__construct();         $this->load->model('modela');         $this->load->model('modelb');         $this->load->model('modelc');     }     public function index()     {         $this->modela->model_funtion();//now can call model function m function of controller.     } } 

2.you can call before using it.

class acontroller extends ci_controller {    public function __construct()     {         parent::__construct();     }     public function index()     {         $this->load->model('modela');         $this->modela->model_funtion();     } } 

3.you can load inside autoload.php.so model can used everywhere(inside controller).


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -