[eluser]4ever[/eluser]
OK, I go to write how I understand CI_loader.
L78
function library
L80 if 1st argument is array make recursive call
L90 exit if 1st argument of class name is not present OR if the controller class is already loaded
L100 load the requested class
Code:
$this->_ci_load_class($library, $params, $object_name);
L116
function model
L122 if 1st argument is array make recursive call
L127 exit if 1st argument of model name is not present
L135 checks format of model name and gets two parts: $path, $model
L144 if ($name == '') $name = $model;
L149 if the model is loaded return
Code:
in_array($name, $this->_ci_models, TRUE)
L154 access the super object:
Code:
$CI =& get_instance();
L161 $model = strtolower($model);
L162-192
Code:
foreach ($this->_ci_model_paths as $mod_path)
{
if ( ! file_exists($mod_path.'models/'.$path.$model.EXT))
{
continue;
}
if ($db_conn !== FALSE AND ! class_exists('CI_DB'))
{
if ($db_conn === TRUE)
{
$db_conn = '';
}
$CI->load->database($db_conn, FALSE, TRUE);
}
if ( ! class_exists('CI_Model'))
{
load_class('Model', 'core');
}
require_once($mod_path.'models/'.$path.$model.EXT);
$model = ucfirst($model);
$CI->$name = new $model();
$this->_ci_models[] = $name;
return;
}
L165 find the file of model
L169-L176 if 3rd fnc argument - DB connection is set ...
make db connection
Code:
$CI->load->database($db_conn, FALSE, TRUE);
L179-181 if class has been defined
load the CORE MODEL
Code:
load_class('Model', 'core');
This has been explain in previous posts of this thread.
L184
REQUIRE the user model
L188-190 It is possible to save the $name as 2nd function argument and to save the object under different name.
Code:
$CI->$name = new $model();
$this->_ci_models[] = $name;
So here the instance has been created and object is saved in super object -> _ci_models array