* If the module and method if defined in workflow, run workflow engine.
This commit is contained in:
@@ -20,10 +20,51 @@
|
||||
include dirname(__FILE__) . '/base/model.class.php';
|
||||
class model extends baseModel
|
||||
{
|
||||
/**
|
||||
* 加载一个模块的model。加载完成后,使用$this->$moduleName来访问这个model对象。
|
||||
* 比如:loadModel('user')引入user模块的model实例对象,可以通过$this->user来访问它。
|
||||
*
|
||||
* Load the model of one module. After loaded, can use $this->$moduleName to visit the model object.
|
||||
*
|
||||
* Extension: set appName as empty.
|
||||
*
|
||||
* @param string $moduleName
|
||||
* @access public
|
||||
* @return object|bool the model object or false if model file not exists.
|
||||
*/
|
||||
public function loadModel($moduleName, $appName = '')
|
||||
{
|
||||
$appName = '';
|
||||
|
||||
if(empty($moduleName)) return false;
|
||||
if(empty($appName)) $appName = $this->appName;
|
||||
|
||||
global $loadedModels;
|
||||
if(isset($loadedModels[$appName][$moduleName]))
|
||||
{
|
||||
$this->$moduleName = $loadedModels[$appName][$moduleName];
|
||||
return $this->$moduleName;
|
||||
}
|
||||
|
||||
$modelFile = $this->app->setModelFile($moduleName, $appName);
|
||||
|
||||
if(!helper::import($modelFile)) return false;
|
||||
$modelClass = class_exists('ext' . $appName . $moduleName. 'model') ? 'ext' . $appName . $moduleName . 'model' : $appName . $moduleName . 'model';
|
||||
if(!class_exists($modelClass))
|
||||
{
|
||||
$modelClass = class_exists('ext' . $moduleName. 'model') ? 'ext' . $moduleName . 'model' : $moduleName . 'model';
|
||||
if(!class_exists($modelClass)) $this->app->triggerError(" The model $modelClass not found", __FILE__, __LINE__, $exit = true);
|
||||
}
|
||||
|
||||
$loadedModels[$appName][$moduleName] = new $modelClass($appName);
|
||||
$this->$moduleName = $loadedModels[$appName][$moduleName];
|
||||
return $this->$moduleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
* Delete one record.
|
||||
*
|
||||
*
|
||||
* @param string $table the table name
|
||||
* @param string $id the id value of the record to be deleted
|
||||
* @access public
|
||||
|
||||
Reference in New Issue
Block a user