Welcome Guest, Not a member yet? Register   Sign In
Loading library with multiple method call
#1

[eluser]Kromack[/eluser]
Hello everybody,

I'm using CI 1.7 without any hack.

I think I found a bug, but I'm not sure, this is related to :

$this->load->library('pagination');

See below :

Code:
class Test extends Controller {


public function Test() {

//$this->load->library('pagination'); //Work's fine

}

public function index() {

//$this->load->library('pagination'); //Work's fine


$this->testt();

}

public function testt() {


$this->load->library('pagination'); //HERE DOESN'T WORK !!

        //Pagination
        
        $config['base_url'] = base_url();
        $config['total_rows'] = '200';
        $config['per_page'] = '3';
        
        $this->pagination->initialize($config);
        
        $data['pagination'] = $this->pagination->create_links();

}


}


Actually, if $this->load->library('pagination'); is in testt() method, I get this error :

Quote:Fatal error: Call to undefined method stdClass::_assign_libraries() in /Users/xxx/Documents/workspace/xxx/system/libraries/Loader.php on line 1038


What are you thinking about this ?

Thank's all Smile
#2

[eluser]Gaz[/eluser]
I've got a similar problem, but I'm also using IgnitedRecord. The error I get is

IgnitedRecord: IR_record: Method _assign_libraries() is not found.
Called on line 1038 in /Users/Gaz/Sites/muzzrace/system/libraries/Loader.php.

Although all of my other IgnitedRecord models work perfectly.

I'm pretty puzzled over this one. Any ideas anybody?

Cheers,
Gaz.
#3

[eluser]ifew[/eluser]
i have same problem
#4

[eluser]Drew J[/eluser]
I'm having this problem also. Has anyone found a solution or the cause?
#5

[eluser]wiredesignz[/eluser]
The fault is not with loading a library per se.

_assign_libraries() is a method in the CI core Model class. It appears that you may have created an empty model somehow (One that does not extend the Model class) or something similar.

Once CI loads a library it attempts to assign a reference to it, to all currently loaded models. The error occurs at that point.
#6

[eluser]Drew J[/eluser]
Thanks for the input, that helped!

I think I found the source of my problem specifically, but I'm still not sure WHY it's a problem.

I have a function in a model that I call via a hook (post_controller_constructor). In this "initialization function", I call load another model and give it a different object name.

So, I get an instance of the $CI object, via $CI =& get_instance(), and then load $CI->load->model('account_model', 'account'); so that I can access it via $this->account everywhere else.

This was the problem, and removing the second function parameter ('account') fixed everything.

However, the problem doesn't occur there. As stated previously, it happens when I try to load a LIBRARY somewhere else. (Seems to only be with libraries as far as I can tell)

Hopefully this might help someone else who comes across this. If anyone can explain further why it does that, that'd be cool too. Smile
#7

[eluser]wiredesignz[/eluser]
[quote author="Drew J" date="1250817025"]... I have a function in a model that I call via a hook (post_controller_constructor). In this "initialization function", I call load another model and give it a different object name.

So, I get an instance of the $CI object, via $CI =& get_instance(), and then load $CI->load->model('account_model', 'account'); so that I can access it via $this->account everywhere else...[/quote]

This sounds scarily complicated, I'm not surprised that you have problems.

Have you tried auto loading your account model? (config/autoload.php)




Theme © iAndrew 2016 - Forum software by © MyBB