php - Codeigniter - autoloading models with aliases -
when manually load models in codeigniter
can specify alias so:
$this->load->model("user_model","user"); //user alias user_model $this->user->getprofile(); //use alias refer actual model
some of these models being extensively used in application , decided autoload them using autoload.php
. know can load them so:
$autoload['model'] = array("user_model","another_model");
however referenced on aliases. want load them existing alias name current code not disturbed.
i guess can have code in autoloaded helper maybe:
$ci= &get_instance(); $ci->user = $ci->user_model;
but wanted check is, can load model alias name while autoloading?
yes can create same alias in in autoload pass array try not possiable alias can create same alias auto loading time.
$autoload['model'] = array(array('users_model', 'users'), array('an_model', 'an'), 'other_model');
or try
$autoload['model'] = array(array('users_model', 'users', false));
for more :- https://github.com/ellislab/codeigniter/issues/2117
Comments
Post a Comment