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

[eluser]TheFuzzy0ne[/eluser]
That's a very good question, and unfortunately there's no way to do that. As far as I can see, this leaves two options.

Option 1 - You load a helper file or something similar, which will reassign the autoloaded model to a name of your liking. Perhaps something like this:

Code:
function reassign_model_names()
{
    $CI =& get_instance();
    $db = $CI->original_model;
    unset($CI->original_model);
    $CI->new_model_name =& $db;
}

...But that's fugly, and clunky.

Option 2 - Override the Loader library with your own method:

./system/application/libraries/MY_Loader.php

# CODE MOVED TO http://ellislab.com/forums/viewthread/110977/#560058

The code above is untested, but should allow you to use an array in your autoloader:

Code:
$autoload['libraries'] = array('database', array('email', NULL, 'email2'), 'session');

The arguments in the array should be just as they would be if you were to call $this->load->library() directly:
Code:
array($library_name, $params, $object_name)

Hope this helps.


Messages In This Thread
Autoload model with a different object name - by El Forum - 04-07-2009, 07:05 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 08:32 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 08:38 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 08:54 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 08:59 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 09:45 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 09:50 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 09:52 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 10:10 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 10:11 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 10:52 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 11:04 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 11:19 AM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:16 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:19 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:19 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:21 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:39 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:44 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 12:52 PM
Autoload model with a different object name - by El Forum - 04-07-2009, 01:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB