Welcome Guest, Not a member yet? Register   Sign In
What's the best way to do it ??
#1

[eluser]josepichu[/eluser]
Hi!

What's the best way to avoid recalculate again an again a data from the database ??

I have in all my header views some values that i load from my DB. Actually I'm accesing it in all my controllers and methods to show it then.

I have proved to load the var value in my constructor to be able in the methods but then when i want to use the var it show me that is undefined.

I know i can do it with var session, but do you Know a better way ?? Hooks??

do you undestands me??

thnks!
#2

[eluser]josepichu[/eluser]
How can i do it with global vars?? something like this:

Code:
class Controller extends CI_Controller {

public $head['value'] = $this->model->method();

function __construct() {

  parent::__construct();
}

function index($param = null) {

            $head['value2'] = $this->model->method2();
            $this->load->view("head.php",$head);

        }

function method1 ($param = null) {

            $head['value3'] = $this->model->method3();
            $this->load->view("head.php",$head);

        }
  
}

but it doesn't work !!
#3

[eluser]josepichu[/eluser]
OK! i have solved it using public vars in my class!

thnks.




Theme © iAndrew 2016 - Forum software by © MyBB