MX_Loader::model PHP Method

model() public method

Load a module model *
public model ( $model, $object_name = NULL, $connect = FALSE )
    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 $this;
        }
        /* check module */
        list($path, $_model) = Modules::find(strtolower($model), $this->_module, 'models/');
        if ($path == FALSE) {
            /* check application & packages */
            parent::model($model, $object_name, $connect);
        } else {
            class_exists('CI_Model', FALSE) or load_class('Model', 'core');
            if ($connect !== FALSE && !class_exists('CI_DB', FALSE)) {
                if ($connect === TRUE) {
                    $connect = '';
                }
                $this->database($connect, FALSE, TRUE);
            }
            Modules::load_file($_model, $path);
            $model = ucfirst($_model);
            CI::$APP->{$_alias} = new $model();
            $this->_ci_models[] = $_alias;
        }
        return $this;
    }

Usage Example

コード例 #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);
 }
All Usage Examples Of MX_Loader::model