Welcome Guest, Not a member yet? Register   Sign In
Autoload model with a different object name
#11

[eluser]RJ[/eluser]
Ok! got it working with this.

Auto-Load:
Code:
$autoload['model'] = array(array('dealer_model', 'dealer', FALSE));

Shop Controller:
Code:
$this->dealer->dealer_model($dealer);

Dealer_model:
Code:
function Dealer_model($dealer = '')

Thanks a million!!!!!!!!!!
#12

[eluser]TheFuzzy0ne[/eluser]
Great stuff. It was just whining that there were not enough parameters. I thought list() would set them to NULL, but obviously it doesn't.

I've edited the model function above, if you're still interested, so you won't need to worry about that third parameter.

I will post back when I've ironed out the kinks in the library() override method too.
#13

[eluser]RJ[/eluser]
Absolutely interested, and i really appreciate the help! I know little but taking your example i will work the forums to help others when i can.

Best
#14

[eluser]TheFuzzy0ne[/eluser]
OK, I'm having some problems with getting this implemented with libraries. The problem is that for autoloaded models, CodeIgniter just passes the array straight through, but the library loader does not, it passes each array segment in one at a time, making it difficult to differentiate between the two formats (an array of library names, and an array containing the configuration).

As it stands, I will have to override the _ci_autoloader() method to get libraries loading properly, but I'm trying to either achieve this by only overriding the _ci_autoloader method(), or by overriding both the library() and model() methods without touching the _ci_autoloader() method (if that makes sense...).

I'm not quite sure on which path to take just yet, but when I figure it out, I'll post my solution.
#15

[eluser]jedd[/eluser]
Isn't it easier just to name your library what you want to call it in the first place?

Call me old-fashioned ...
#16

[eluser]RJ[/eluser]
Ok, sounds time consuming, unless you have another implementation of the same functioning I can simply load in the constructor. I appreciate your time and effort!
#17

[eluser]RJ[/eluser]
[quote author="jedd" date="1239146348"]Isn't it easier just to name your library what you want to call it in the first place?

Call me old-fashioned ...[/quote]

The original question goes back to renaming a Model.
#18

[eluser]jedd[/eluser]
[quote author="bullspit" date="1239146471"][quote author="jedd" date="1239146348"]Isn't it easier just to name your library what you want to call it in the first place?

Call me old-fashioned ...[/quote]

The original question goes back to renaming a Model.[/quote]

Isn't it easier just to name your model what you want to call it in the first place?
#19

[eluser]TheFuzzy0ne[/eluser]
[quote author="jedd" date="1239146348"]Isn't it easier just to name your library what you want to call it in the first place?[/quote]

Because you might want multiple instances of any given class instantiated in the global scope of the CI Super Object.
#20

[eluser]jedd[/eluser]
Fuzzy - entirely grok that requirement. But can't imagine a situation where you'd need to autoload multiple instances.




Theme © iAndrew 2016 - Forum software by © MyBB