Welcome Guest, Not a member yet? Register   Sign In
Error - Product / Categories - Views
#1

[eluser]MEM[/eluser]
By long reasons, I have to call on Categories Controller, some product Model methods:
I have the following:

Code:
//Fetch product list
$data['listaprodutos'] = $this->M_Produto->getProdutosByCategoria($intProdCat);

I'm getting an error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: C_Categoria::$M_Produto
Filename: controllers/c_categoria.php
Line Number: 33
Fatal error: Call to a member function getProdutosByCategoria() on a non-object

Can anyone help me to figured out, why am I having this error, and how to solve it?


Kind Regards,
Márcio
#2

[eluser]MEM[/eluser]
Ok. This was because I was not loading the model before calling it.


However, on this same C_Category Controller, I call the M_Category Model without using
Code:
$this->load->Model();
, and no error is displayed and all works fine.

Can anyone explain me why?


Regards,
Márcio
#3

[eluser]jedd[/eluser]
[quote author="MEM" date="1258926759"]
However, on this same C_Category Controller, I call the M_Category Model without using
Code:
$this->load->Model();
, and no error is displayed and all works fine.

Can anyone explain me why?
[/quote]

Oh .. a game of trivia pursuit! How fun Wink

Are you suggesting that you're loading it in MY_Controller, or autoload.php, or something, and have just forgotten?

grep is your friend. Wink

You might also want to follow the [url="/user_guide/general/models.html"]CI User Guide[/url]'s naming standards for model names.
#4

[eluser]MEM[/eluser]
[quote author="jedd" date="1258930905"]
Oh .. a game of trivia pursuit! How fun Wink

Are you suggesting that you're loading it in MY_Controller, or autoload.php, or something, and have just forgotten?
[/quote]

Tlim Tlim Tlim Tlim!!!! Yes! You got it right, and you have just won my big thanks on this trivia! :-)

That's right, I was having my model autoloaded, I just forget that that was possible. Confused
How much newbie can we get?


Thanks for the name convention tip.


Cheers,
Márcio




Theme © iAndrew 2016 - Forum software by © MyBB