Welcome Guest, Not a member yet? Register   Sign In
Aliasing autoloaded models
#1

[eluser]Vince Stross[/eluser]
I'm trying to set an alias for an autoloaded model. I've tried the following:

Code:
$autoload['model'] = array(array('alias'=>'some_model'),'other_models');

CI accepts this format without an error, but when I try to access the model using $this->alias->function() it is clearly not loaded.

I originally tried the conventional syntax with the model name and then the alias but CI returned an error.

Code:
$autoload['model'] = array(array('some_model'=>'alias'),'other_models');

any ideas?
#2

[eluser]wiredesignz[/eluser]
Looking at the Model loader source it is not possible to alias an array() of Models.

You could try this (totally untested idea)
Code:
class Alias_model extends Model

function Alias_Model()
{
    parent::Model();
    $this->load->model('model','alias');
    $this->load->model('model','alias');
    $this->load->model('model','alias');
}
#3

[eluser]Vince Stross[/eluser]
works perfect!

Thanks for the quick response and great idea.




Theme © iAndrew 2016 - Forum software by © MyBB