Faster Way to Load Models and Helpers

#1
[eluser]ShoeLace1291[/eluser]
I have controllers that use the same models, helpers, and libraries in every function in that controller. Is there a way to load models, etc one time in the beginning of a controller instead of loading it in every single function in that controller? I don't want to autoload it(I already know it so don't explain it). Something like

<?php

class Page extends Controller {

$this->load->model('pagemodel');

function index(){

$this->pagemodel->page();

}

function another(){

$this->pagemodel->page();

}
}

#2
[eluser]WebsiteDuck[/eluser]
Code:
class Page extends Controller {

    function __construct(){  

        parent::Controller();    

        $this->load->model('pagemodel');

    }

    function index(){

      $this->pagemodel->page();
    
    }

    function another(){

      $this->pagemodel->page();

    }
}

#3
[eluser]Sbioko[/eluser]
Code:
class Page extends Controller {

    function Page() {
        $this->load->model(‘pagemodel’);
        $this->pagemodel->page();
    }

    function index(){
    }

    function another(){
    }
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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