CodeIgniter Forums
Loading Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Loading Model (/thread-57029.html)



Loading Model - El Forum - 02-08-2013

[eluser]Unknown[/eluser]
I got a view and I'm trying to retrieve some data from a model, executing the following lines:

Quote:$this->load->model('clientes_model');
$data = $this->clientes_model->getCliente(1);

But I'm getting the follow message.

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$vendedores_model

Filename: views/template.php

Line Number: 3


If I load another model, works fine:

Quote:$this->load->model('pedidos_model');
$data = $this->pedidos_model->getPedido(1);

Actually this is the only model that is loaded normally, any other I try, I get the message.


Here's my model (example):

Quote:class Clientes_model extends CI_Model{

function getClient($id){

return 'exampleClient'.$id

}
}


Quote:class Pedidos_model extends CI_Model{

function getPedido($id){

return 'examplePedido'.$id

}
}


Somebody can help me with this?
Both models are declared exactly alike.


Loading Model - El Forum - 02-08-2013

[eluser]Aken[/eluser]
You don't want to load and retrieve data from your models in your view. That's what your controller is for.