Welcome Guest, Not a member yet? Register   Sign In
Loading two models in one view, causes problems?
#1

[eluser]geshan[/eluser]
Hello all code igniter users,
I had to load two models in the same view how can I do it? it shows no erros when I load the second model in the view but when I call a function of the second model it gives me error says the 2nd model name is not identified. How can I load two models in one view?
#2

[eluser]xwero[/eluser]
It should be no problem if you load the models in your controller.
#3

[eluser]Tom Glover[/eluser]
Load your models in the controller and then out put the function a var that is handled by the view.

An example:
Controller:
Code:
function index()
    {
        $this->load->model('model_1');
        $this->load->model('model_2');
        
        $data['out1'] = $this->model_1->function1($vars);
        $data['out2'] = $this->model_2->function2($vars);
        
        $this->load->view('view_1',$data)
        // just call the var out1 or out 2 where needed in the view file.
    }

Just echo the the out1 or out2 where needed in the view file.

Hope this helps.




Theme © iAndrew 2016 - Forum software by © MyBB