Welcome Guest, Not a member yet? Register   Sign In
How to make it available in every function?
#1

[eluser]CocoMansur[/eluser]
Hi,

i have a model that retrieves data from a database and was returned to a variable in the controller then will be displayed in view.

my problem is, in every function within the controller i always have to call that model. is there a way that will do this in default without calling the model on each of the functions within the controller?

here is a sample code:

Code:
class Base extends CI_Controller{

  public function welcome(){
   $data['get_latest'] = $this->log_templates->get_latest_log();
   (other codes here...)
   $this->load->view('template',$data);
  }
  
  public function marketting(){
   $data['get_latest'] = $this->log_templates->get_latest_log();
   (other codes here...)
   $this->load->view('template',$data);
  }

  public function documentation(){
   $data['get_latest'] = $this->log_templates->get_latest_log();
   (other codes here...)
   $this->load->view('template',$data);
  }

}


Messages In This Thread
How to make it available in every function? - by El Forum - 03-02-2012, 11:03 PM
How to make it available in every function? - by El Forum - 03-03-2012, 01:03 AM
How to make it available in every function? - by El Forum - 03-03-2012, 01:22 AM
How to make it available in every function? - by El Forum - 03-03-2012, 01:30 AM
How to make it available in every function? - by El Forum - 03-04-2012, 08:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB