Welcome Guest, Not a member yet? Register   Sign In
is it a good practice to load the model in the constructor function??
#1

[eluser]zoreli[/eluser]
I would like to know...can I load the model in my constructor function instead of loading it for each function within that controller?

Lets say that I have 5 functions that use same model. Instad of loadin the same model in all 5 functions, should I load the controller in the construcor function like this?

Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class BackOfficeUsers extends MY_Controller
{

    // constructor function
    public function __construct()
    {
        parent::__construct();
        $this->load->model('backOfficeUsersModel'); // load it here??
    } // end of constructor function

Is this good practice or no??


Messages In This Thread
is it a good practice to load the model in the constructor function?? - by El Forum - 10-06-2012, 03:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB