CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

Bug in core/Loader.php

Open aanbar opened this issue 13 years ago • 2 comments

The following line 225 in core/Loader.php should be changed from

$this->model(is_int($key) ? $value : $key, $value);

To the following:

is_int($key) ? $this->model($value, '', $db_conn) : $this->model($key, $value, $db_conn);

Otherwise it will generate errors when loading multiple models which resides in subfolders by passing an array, I've had to change it manually for now to get things working in my project.

aanbar avatar Sep 12 '13 15:09 aanbar

What kind of errors?

narfbg avatar Sep 12 '13 20:09 narfbg

I should have explained it further,

The current code is passing an alias to models loader each time, which is OK when the models aren't in subfolders because users_model => users_model

but for example if you have something like subfolder/users_model the current code will load users_model & give it an alias of "subfolder/users_model" so you cannot access it using $this->users_model (it's not there because it was loaded with different name).

Also the current code doesn't account for database loading or something (I don't know what's the use of this, but I thought I'd include it anyway in the fix).

aanbar avatar Sep 12 '13 21:09 aanbar