Browse Source

Update: Fixed 多次调用获取用户数据库连接问题

Jinhui Zhu 5 years ago
parent
commit
996375c035
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/Driver/Pdo/Driver.php

+ 3 - 3
src/Driver/Pdo/Driver.php

@@ -282,9 +282,9 @@ class Driver extends \Qii\Driver\Base implements \Qii\Driver\Intf
      */
      */
     public function setError()
     public function setError()
     {
     {
-        if ($this->connection->getConnectionBySQL($this->sql)->errorCode() != '00000') {
+        if ($this->db['CURRENT']->errorCode() != '00000') {
             $this->_errorInfo[$this->queryTimes]['sql'] = $this->sql;
             $this->_errorInfo[$this->queryTimes]['sql'] = $this->sql;
-            $this->_errorInfo[$this->queryTimes]['error'] = $this->iconv($this->connection->getConnectionBySQL($this->sql)->errorInfo());
+            $this->_errorInfo[$this->queryTimes]['error'] = $this->iconv($this->db['CURRENT']->errorInfo());
             $this->response = \Qii\Driver\Response::Fail('pdo.error', $this->_errorInfo);
             $this->response = \Qii\Driver\Response::Fail('pdo.error', $this->_errorInfo);
         }
         }
     }
     }
@@ -299,7 +299,7 @@ class Driver extends \Qii\Driver\Base implements \Qii\Driver\Intf
         if (!$this->rs) {
         if (!$this->rs) {
             return true;
             return true;
         }
         }
-        if ($this->connection->getConnectionBySQL($this->sql)->errorCode() != '00000') {
+        if ($this->db['CURRENT']->errorCode() != '00000') {
             return true;
             return true;
         }
         }
         return false;
         return false;