Преглед изворни кода

Update:将提示的错误信息转换成UTF8

Zhu Jinhui пре 7 година
родитељ
комит
4b4d34daf2

+ 2 - 2
Qii/Driver/Mysql/Driver.php

@@ -234,8 +234,8 @@ class Driver extends \Qii\Driver\Base implements \Qii\Driver\Intf
 	{
 		if (\mysql_errno($this->db['CURRENT'])) {
 			$this->_errorInfo[$this->queryTimes]['sql'] = $this->sql;
-			$this->_errorInfo[$this->queryTimes]['error'][2] = \mysql_error($this->db['CURRENT']);
-			$this->response = \Qii\Driver\Response::Fail('pdo.error', $this->_errorInfo);
+			$this->_errorInfo[$this->queryTimes]['error'][2] = iconv('GB2312', 'UTF-8', \mysql_error($this->db['CURRENT']));
+			$this->response = \Qii\Driver\Response::Fail('mysql.error', $this->_errorInfo);
 		}
 	}
 

+ 2 - 2
Qii/Driver/Mysqli/Driver.php

@@ -255,8 +255,8 @@ class Driver extends \Qii\Driver\Base implements \Qii\Driver\Intf
 	{
 		if (\mysqli_errno($this->db['CURRENT'])) {
 			$this->_errorInfo[$this->queryTimes]['sql'] = $this->sql;
-			$this->_errorInfo[$this->queryTimes]['error'][2] = \mysqli_error($this->db['CURRENT']);
-			$this->response = \Qii\Driver\Response::Fail('pdo.error', $this->_errorInfo);
+			$this->_errorInfo[$this->queryTimes]['error'][2] = iconv('GB2312', 'UTF-8', \mysqli_error($this->db['CURRENT']));
+			$this->response = \Qii\Driver\Response::Fail('mysqli.error', $this->_errorInfo);
 		}
 	}
 

+ 1 - 1
Qii/Driver/Pdo/Connection.php

@@ -68,7 +68,7 @@ class Connection extends \Qii\Driver\ConnBase implements \Qii\Driver\ConnIntf
 			}
 			return new \PDO($dsn, $dbInfo['user'], $dbInfo['password']);
 		} catch (Exception  $e) {
-			throw new \Qii\Exceptions\Errors(\Qii::i(1500, $dbInfo['host'], $dbInfo['user'], $dbInfo['password'], $dbInfo['db'], $e->getMessage()), __LINE__);
+			throw new \Qii\Exceptions\Errors(\Qii::i(1500, $dbInfo['host'], $dbInfo['user'], $dbInfo['password'], $dbInfo['db'], iconv('GB2312', 'UTF-8', $e->getMessage())), __LINE__);
 		}
 	}
 }

+ 1 - 1
Qii/Driver/Pdo/Driver.php

@@ -284,7 +284,7 @@ class Driver extends \Qii\Driver\Base implements \Qii\Driver\Intf
     {
         if ($this->connection->getConnectionBySQL($this->sql)->errorCode() != '00000') {
             $this->_errorInfo[$this->queryTimes]['sql'] = $this->sql;
-            $this->_errorInfo[$this->queryTimes]['error'] = $this->connection->getConnectionBySQL($this->sql)->errorInfo();
+            $this->_errorInfo[$this->queryTimes]['error'] = iconv('GB2312', 'UTF-8', $this->connection->getConnectionBySQL($this->sql)->errorInfo());
             $this->response = \Qii\Driver\Response::Fail('pdo.error', $this->_errorInfo);
         }
     }