* [refac bug #55390] Set errorInfo to PDOException.

This commit is contained in:
wangyidong
2024-09-14 14:07:55 +08:00
committed by 孙广明
parent ebd66a9a6a
commit 186314a756
2 changed files with 7 additions and 13 deletions
+3 -4
View File
@@ -102,10 +102,9 @@ class dbh
*/
public function sqlError(object $exception)
{
$sql = $this->sql;
$message = $exception->getMessage();
$message .= " ,the sql is: '{$sql}'";
throw new PDOException($message);
$newException = new PDOException($exception->getMessage() . " ,the sql is: '{$this->sql}'");
$newException->errorInfo = $exception->errorInfo;
throw $newException;
}
/**
+4 -9
View File
@@ -1147,7 +1147,7 @@ class upgradeModel extends model
static $mysqlVersion;
if($mysqlVersion === null) $mysqlVersion = $this->loadModel('install')->getDatabaseVersion();
$ignoreCode = array('1050', '1054', '1060', '1091', '1061'); // Get ignore code when execing.
$ignoreCode = '|1050|1054|1060|1091|1061|';
$sqls = $this->parseToSqls($sqlFile); // Get sqls in the file.
foreach($sqls as $sql)
{
@@ -1177,14 +1177,9 @@ class upgradeModel extends model
}
catch(PDOException $e)
{
$message = $e->getMessage();
$isIgnore = false;
foreach($ignoreCode as $errorCode)
{
if($isIgnore) break;
if(strpos($message, $errorCode) !== false) $isIgnore = true;
}
if(!$isIgnore) static::$errors[] = $message;
$errorInfo = $e->errorInfo;
$errorCode = !empty($errorInfo) ? $errorInfo[1] : '';
if(strpos($ignoreCode, "|$errorCode|") === false) static::$errors[] = $e->getMessage();
}
}
return true;