mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fix #17486: Fixed error when using batch() without $db parameter with MSSQL
This commit is contained in:
committed by
Alexander Makarov
parent
c670073ffb
commit
4b768a86f5
@ -4,7 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.25 under development
|
||||
------------------------
|
||||
|
||||
- no changes in this release.
|
||||
- Bug #17486: Fixed error when using `batch()` without `$db` parameter with MSSQL (alexkart)
|
||||
|
||||
|
||||
2.0.24 July 30, 2019
|
||||
|
||||
@ -151,8 +151,8 @@ class BatchQueryResult extends BaseObject implements \Iterator
|
||||
|
||||
/**
|
||||
* Reads and collects rows for batch
|
||||
* @since 2.0.23
|
||||
* @return array
|
||||
* @since 2.0.23
|
||||
*/
|
||||
protected function getRows()
|
||||
{
|
||||
@ -165,7 +165,7 @@ class BatchQueryResult extends BaseObject implements \Iterator
|
||||
}
|
||||
} catch (\PDOException $e) {
|
||||
$errorCode = isset($e->errorInfo[1]) ? $e->errorInfo[1] : null;
|
||||
if ($this->db->driverName !== 'sqlsrv' || $errorCode !== $this->mssqlNoMoreRowsErrorCode) {
|
||||
if ($this->getDbDriverName() !== 'sqlsrv' || $errorCode !== $this->mssqlNoMoreRowsErrorCode) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@ -202,4 +202,22 @@ class BatchQueryResult extends BaseObject implements \Iterator
|
||||
{
|
||||
return !empty($this->_batch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets db driver name from the db connection that is passed to the `batch()`, if it is not passed it uses
|
||||
* connection from the active record model
|
||||
* @return string|null
|
||||
*/
|
||||
private function getDbDriverName()
|
||||
{
|
||||
if (isset($this->db->driverName)) {
|
||||
return $this->db->driverName;
|
||||
}
|
||||
|
||||
if (isset($this->_batch[0]->db->driverName)) {
|
||||
return $this->_batch[0]->db->driverName;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user