Commit 06bbf017 by tof06

Fixes #4342

parent 093cb97f
...@@ -68,6 +68,7 @@ Yii Framework 2 Change Log ...@@ -68,6 +68,7 @@ Yii Framework 2 Change Log
- Bug #4162: Fixed bug where schema name was not used in ’SHOW CREATE TABLE’ query in `yii\db\mysql\Schema` (stevekr) - Bug #4162: Fixed bug where schema name was not used in ’SHOW CREATE TABLE’ query in `yii\db\mysql\Schema` (stevekr)
- Bug #4241: `yii\widgets\Pjax` was incorrectly setting container id (mitalcoi) - Bug #4241: `yii\widgets\Pjax` was incorrectly setting container id (mitalcoi)
- Bug #4276: Added check for UPLOAD_ERR_NO_FILE in `yii\web\UploadedFile` and return null if no file was uploaded (OmgDef) - Bug #4276: Added check for UPLOAD_ERR_NO_FILE in `yii\web\UploadedFile` and return null if no file was uploaded (OmgDef)
- Bug #4342: mssql (dblib) driver does not support getting attributes (tof06)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark) - Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul) - Bug: URL encoding for the route parameter added to `\yii\web\UrlManager` (klimov-paul)
- Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue) - Bug: Fixed the bug that requesting protected or private action methods would cause 500 error instead of 404 (qiangxue)
......
...@@ -61,4 +61,23 @@ class PDO extends \PDO ...@@ -61,4 +61,23 @@ class PDO extends \PDO
return true; return true;
} }
/**
* Retrieve a database connection attribute.
* It is necessary to override PDO's method as some MSSQL PDO driver (e.g. dblib) does not
* support getting attributes
*/
public function getAttribute($attribute)
{
try {
return parent::getAttribute($attribute);
} catch (\PDOException $e) {
switch ($attribute) {
case PDO::ATTR_SERVER_VERSION:
return $this->query("SELECT SERVERPROPERTY('productversion')")->fetchColumn();
default:
throw $e;
}
}
}
} }
...@@ -17,6 +17,8 @@ use yii\base\InvalidParamException; ...@@ -17,6 +17,8 @@ use yii\base\InvalidParamException;
*/ */
class QueryBuilder extends \yii\db\QueryBuilder class QueryBuilder extends \yii\db\QueryBuilder
{ {
protected $_oldMssql;
/** /**
* @var array mapping from abstract column types (keys) to physical column types (values). * @var array mapping from abstract column types (keys) to physical column types (values).
*/ */
...@@ -189,8 +191,7 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -189,8 +191,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
$originalOrdering = $this->buildOrderBy($query->orderBy); $originalOrdering = $this->buildOrderBy($query->orderBy);
if ($query->select) { if ($query->select) {
$select = implode(', ', $query->select); $select = implode(', ', $query->select);
} } else {
else {
$select = $query->select = '*'; $select = $query->select = '*';
} }
if ($select === '*') { if ($select === '*') {
...@@ -238,8 +239,11 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -238,8 +239,11 @@ class QueryBuilder extends \yii\db\QueryBuilder
*/ */
protected function isOldMssql() protected function isOldMssql()
{ {
$pdo = $this->db->getSlavePdo(); if ($this->_oldMssql === null) {
$version = preg_split("/\./", $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION)); $pdo = $this->db->getSlavePdo();
return $version[0] < 11; $version = preg_split("/\./", $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION));
$this->_oldMssql = $version[0] < 11;
}
return $this->_oldMssql;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment