This commit is contained in:
wangyidong
2020-12-17 11:28:33 +08:00
parent 64a728eb6f
commit 9e1e418e5a
3 changed files with 37 additions and 34 deletions
+32 -1
View File
@@ -268,7 +268,7 @@ class baseHelper
}
/**
* Encrypt password
* Encrypt password.
*
* @param string $password
* @static
@@ -696,6 +696,37 @@ class baseHelper
session_id($sessionID);
session_start();
}
/**
* Check DB to repair table.
*
* @param object $exception
* @static
* @access public
* @return string
*/
public static function checkDB2Repair($exception)
{
global $config, $lang;
$repairCode = '|1034|1035|1194|1195|1459|';
$errorInfo = $exception->errorInfo;
$errorCode = $errorInfo[1];
$errorMsg = $errorInfo[2];
$message = $exception->getMessage();
if(strpos($repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false) or strpos($message, 'repair') !== false)
{
if(isset($config->framework->autoRepairTable) and $config->framework->autoRepairTable)
{
header("location: " . $config->webRoot . 'checktable.php');
exit;
}
return $lang->repairTable;
}
return null;
}
}
//------------------------------- 常用函数。Some tool functions.-------------------------------//
+2 -14
View File
@@ -128,21 +128,9 @@ class router extends baseRouter
{
$commonSettings = $this->dbh->query('SELECT `key`, value FROM' . TABLE_CONFIG . "WHERE `owner`='system' AND `module`='custom' and `key` in ('productProject','URAndSR','URSRName','storyRequirement','hourPoint')")->fetchAll();
}
catch (PDOException $exception)
catch (PDOException $exception)
{
$repairCode = '|1034|1035|1194|1195|1459|';
$errorInfo = $exception->errorInfo;
$errorCode = $errorInfo[1];
$errorMsg = $errorInfo[2];
$message = $exception->getMessage();
if(strpos($repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false) or strpos($message, 'repair') !== false)
{
if(isset($config->framework->autoRepairTable) and $config->framework->autoRepairTable)
{
header("location: " . $config->webRoot . 'checktable.php');
exit;
}
}
helper::checkDB2Repair($exception);
}
}
+3 -19
View File
@@ -136,15 +136,6 @@ class baseDAO
*/
public $autoLang;
/**
* 需要修复表的错误代码
* The sql code of need repair table.
*
* @var string
* @access public
*/
public $repairCode = '|1034|1035|1194|1195|1459|';
/**
* 执行的请求,所有的查询都保存在该数组。
* The queries executed. Every query will be saved in this array.
@@ -1383,16 +1374,9 @@ class baseDAO
*/
public function sqlError($exception)
{
$errorInfo = $exception->errorInfo;
$errorCode = $errorInfo[1];
$errorMsg = $errorInfo[2];
$message = $exception->getMessage();
if(strpos($this->repairCode, "|$errorCode|") !== false or ($errorCode == '1016' and strpos($errorMsg, 'errno: 145') !== false) or strpos($message, 'repair') !== false)
{
global $config;
if(isset($config->framework->autoRepairTable) and $config->framework->autoRepairTable) die(js::locate($config->webRoot . 'checktable.php', 'top'));
$message .= ' ' . $this->lang->repairTable;
}
$message = $exception->getMessage();
$message .= ' ' . helper::checkDB2Repair($exception);
$sql = $this->sqlobj->get();
$this->app->triggerError($message . "<p>The sql is: $sql</p>", __FILE__, __LINE__, $exit = true);
}