• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.