model() public method

Load a module model *
public model ( $model, $object_name = NULL, $connect = FALSE )
コード例 #1
0
ファイル: MY_Loader.php プロジェクト: Rotron/hero
 function model($model, $object_name = NULL, $connect = FALSE)
 {
     if (!is_array($model)) {
         self::define_module($model);
     }
     return parent::model($model, $object_name, $connect);
 }
コード例 #2
0
ファイル: AG_Loader.php プロジェクト: vitalik199415/ozar
 /** Load a module model **/
 public function model($model, $object_name = NULL, $connect = FALSE)
 {
     if (is_array($model)) {
         return $this->models($model);
     }
     $_alias = $object_name or $_alias = basename($model);
     if (in_array($_alias, $this->_ci_models, TRUE)) {
         return CI::$APP->{$_alias};
     }
     /* check module */
     list($path, $_model) = Modules::find(strtolower($model), $this->_module, 'models/');
     //AG_ ***************************
     if ($path == FALSE) {
         $model_e = explode('/', $model, 2);
         if (count($model_e) > 1) {
             list($path, $_model) = Modules::find(strtolower($model_e[1]), $model_e[0], 'models/');
         }
     }
     //AG_ ----------------------------
     if ($path == FALSE) {
         /* check application & packages */
         parent::model($model, $object_name);
     } else {
         class_exists('CI_Model', FALSE) or load_class('Model', 'core');
         if ($connect !== FALSE and !class_exists('CI_DB', FALSE)) {
             if ($connect === TRUE) {
                 $connect = '';
             }
             $this->database($connect, FALSE, TRUE);
         }
         Modules::load_file($_model, $path);
         $model = ucfirst($_model);
         if (class_exists(users_class_prefix . $model)) {
             $model = users_class_prefix . $model;
         }
         CI::$APP->{$_alias} = new $model();
         $this->_ci_models[] = $_alias;
     }
     return CI::$APP->{$_alias};
 }