From 7b0a8a5bb05087bb84fd552fc709dfe4afba11a1 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 2 Aug 2021 16:59:14 +0800 Subject: [PATCH] * fix bug for loadModel. --- framework/base/model.class.php | 47 +++++++++++++++++----------------- module/execution/model.php | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/framework/base/model.class.php b/framework/base/model.class.php index 5feac4a9cb..ee7c88676e 100644 --- a/framework/base/model.class.php +++ b/framework/base/model.class.php @@ -7,7 +7,7 @@ * * The author disclaims copyright to this source code. In place of * a legal notice, here is a blessing: - * + * * May you do good and not evil. * May you find forgiveness for yourself and forgive others. * May you share freely, never taking more than you give. @@ -17,7 +17,7 @@ class baseModel /** * 全局对象$app。 * The global $app object. - * + * * @var object * @access public */ @@ -26,7 +26,7 @@ class baseModel /** * 应用名称$appName。 * The global appName. - * + * * @var string * @access public */ @@ -35,7 +35,7 @@ class baseModel /** * 全局对象$config。 * The global $config object. - * + * * @var object * @access public */ @@ -44,7 +44,7 @@ class baseModel /** * 全局对象$lang。 * The global $lang object. - * + * * @var object * @access public */ @@ -53,7 +53,7 @@ class baseModel /** * 全局对象$dbh,数据库连接句柄。 * The global $dbh object, the database connection handler. - * + * * @var object * @access public */ @@ -62,7 +62,7 @@ class baseModel /** * $dao对象,用于访问或者更新数据库。 * The $dao object, used to access or update database. - * + * * @var object * @access public */ @@ -71,7 +71,7 @@ class baseModel /** * $post对象,用于访问$_POST变量。 * The $post object, used to access the $_POST var. - * + * * @var object * @access public */ @@ -80,7 +80,7 @@ class baseModel /** * $get对象,用于访问$_GET变量。 * The $get object, used to access the $_GET var. - * + * * @var object * @access public */ @@ -89,7 +89,7 @@ class baseModel /** * $session对象,用于访问$_SESSION变量。 * The $session object, used to access the $_SESSION var. - * + * * @var object * @access public */ @@ -98,7 +98,7 @@ class baseModel /** * $server对象,用于访问$_SERVER变量。 * The $server object, used to access the $_SERVER var. - * + * * @var object * @access public */ @@ -107,7 +107,7 @@ class baseModel /** * $cookie对象,用于访问$_COOKIE变量。 * The $cookie object, used to access the $_COOKIE var. - * + * * @var object * @access public */ @@ -116,7 +116,7 @@ class baseModel /** * $global对象,用于访问$_GLOBAL变量。 * The $global object, used to access the $_GLOBAL var. - * + * * @var object * @access public */ @@ -126,12 +126,12 @@ class baseModel * 构造方法。 * 1. 将全局变量设为model类的成员变量,方便model的派生类调用; * 2. 设置$config, $lang, $dbh, $dao。 - * + * * The construct function. * 1. global the global vars, refer them by the class member such as $this->app. * 2. set the pathes, config, lang of current module * - * @param string $appName + * @param string $appName * @access public * @return void */ @@ -158,7 +158,7 @@ class baseModel * 这个方法通过去掉该model类名的'ext'和'model'字符串,来获取当前模块名。 * 不要使用$app->getModuleName(),因为其返回的是用户请求的模块名。 * 另一个model可以通过loadModel()加载进来,与请求的模块名不一致。 - * + * * Get the module name of this model. Not the module user visiting. * * This method replace the 'ext' and 'model' string from the model class name, thus get the module name. @@ -180,7 +180,7 @@ class baseModel /** * 设置全局超级变量。 * Set the super vars. - * + * * @access public * @return void */ @@ -198,7 +198,7 @@ class baseModel * 比如:loadModel('user')引入user模块的model实例对象,可以通过$this->user来访问它。 * * Load the model of one module. After loaded, can use $this->$moduleName to visit the model object. - * + * * @param string $moduleName * @access public * @return object|bool the model object or false if model file not exists. @@ -207,6 +207,7 @@ class baseModel { if(empty($moduleName)) return false; if(empty($appName)) $appName = $this->appName; + $moduleName = strtolower($moduleName); global $loadedModels; if(isset($loadedModels[$appName][$moduleName])) @@ -242,9 +243,9 @@ class baseModel * And call them by the ext/model/$extension.php like this: $this->loadExtension('myextension')->method(). * You can encrypt the code in ext/model/class/*.class.php. * Because the framework will merge the extension files in ext/model/*.php to the module/model.php. - * - * @param string $extensionName - * @param string $moduleName + * + * @param string $extensionName + * @param string $moduleName * @access public * @return void */ @@ -278,7 +279,7 @@ class baseModel /** * 加载DAO。 * Load DAO. - * + * * @access public * @return void */ @@ -290,7 +291,7 @@ class baseModel /** * 删除记录。 * Delete one record. - * + * * @param string $table the table name * @param string $id the id value of the record to be deleted * @access public diff --git a/module/execution/model.php b/module/execution/model.php index b2a440d805..c5301e4413 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -486,7 +486,7 @@ class executionModel extends model if(isset($this->config->maxVersion)) { $execution->planDuration = $this->loadModel('programplan')->getDuration($execution->begin, $execution->end); - if(!empty($execution->realBegan) and !empty($execution->realEnd)) $execution->realDuration = $this->loadModel('programplan')->getDuration($execution->realBegan, $execution->realEnd); + if(!empty($execution->realBegan) and !empty($execution->realEnd)) $execution->realDuration = $this->programplan->getDuration($execution->realBegan, $execution->realEnd); } /* Redefines the language entries for the fields in the project table. */