Welcome Guest, Not a member yet? Register   Sign In
Loading a library from within a model not working??
#1

[eluser]Mackstar[/eluser]
Hi I have a library with a class called Encoding,

the file is saved as Encoding.php

When I call the library from within a controller it is working propery.

But when I use it from inside a model it is giving me Call to undefined method stdClass::function_name() errors.

Why is this??, I am calling the function from $this->encoding-> function_name();

When I call $this->load->library('Encoding'); from the model, I have put test code in the Encoding class constructer and it works, so the class is being called but the model doesn't seem to go to to $this->encoding or $this->Encoding

I have tried get_class($this->encoding); and I get nothing. I run this from a controller and it works...?

Any help is appreciated...

Richard
#2

[eluser]Mackstar[/eluser]
I managed to find an answer here

http://ellislab.com/forums/viewthread/109605/

Although I am disappointed that I have to go to such lengths to get libraries loaded into models.

What do other people think about models being dependent on other models..?

I don't think it is too bad as surely some models should have the ability to change what happens in another??

Cheers

Richard
#3

[eluser]TheFuzzy0ne[/eluser]
The main problem is that when a model is loaded, none of the other models are updated with references to that model, unless you do it manually. However, when a library is loaded, all models should be automatically updated with a reference to that library, so I'm not sure what the problem is. Please could you show us some code?




Theme © iAndrew 2016 - Forum software by © MyBB