/** * get_model : get instance of specified model * @param string $model model name * @param mixed $params parameter for new model ctor * @return object instance of model */ public function get_model($model = '', $params = null) { if (empty($model)) { $model = 'base_model'; } $new_model = basename($model); // if( !class_exists($new_model, false) ){ // $cls_file = APP_PATH.'/models/'.$model.'.php'; // if( !file_exists($cls_file) ){ // return false; // } // require_once $cls_file; // } if (!AppServer::load_class($model, 'models', true)) { throw new Exception('Failed to load : ' . $model, 404); } // create instance $obj = new $new_model($params); return $obj; }