Welcome Guest, Not a member yet? Register   Sign In
Renaming auto-loaded models
#1

[eluser]richthegeek[/eluser]
Hi,

There isn't anything about this in the docs that I can, but is there a way to rename auto-loaded models like how its done with $this->load->model?

Eg, if I wanted to do it manually I'd do;
Code:
$this->load->model( "glob_model", "_glob" );

However, it's in my autoload as;
Code:
$autoload['model'] = array('glob_model',...);

Any help?
#2

[eluser]Colin Williams[/eluser]
In your controller constructor, do something like

Code:
$this->_glob = $this->glob_model
// If PHP4, $this->_glob =& $this->glob_model
#3

[eluser]jedd[/eluser]
How about shifting the model loading from config/autoload.php to MY_Controller's constructor? If you're resolved to modifying each controller's constructor, or implementing a MY_Controller to assign a new $this-> variable - it seems comparable in terms of complexity.

I might be tempted to put a note in config/autoload.php near the models section to advise wanderers of what you've done, lest they be confused.

I guess the other option would be to extend the Loader class (assuming autoload uses that) to allow for a set of key-value pairings for model loading, so you can rename them that way. Check the source to see if that would work.

The simplest method might just be to call your models something that you're happy with in the first place, rather than have two model names per model. Call me old-fashioned ....
#4

[eluser]Johan André[/eluser]
[quote author="jedd" date="1260918265"]Call me old-fashioned ....[/quote]

Sometimes the old proven way is the way to go! Smile




Theme © iAndrew 2016 - Forum software by © MyBB