mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00
Fixes #4342
This commit is contained in:
@ -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 #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 #4342: mssql (dblib) driver does not support getting attributes (tof06)
|
||||
- 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: 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
|
||||
|
||||
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;
|
||||
*/
|
||||
class QueryBuilder extends \yii\db\QueryBuilder
|
||||
{
|
||||
protected $_oldMssql;
|
||||
|
||||
/**
|
||||
* @var array mapping from abstract column types (keys) to physical column types (values).
|
||||
*/
|
||||
@ -189,8 +191,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
$originalOrdering = $this->buildOrderBy($query->orderBy);
|
||||
if ($query->select) {
|
||||
$select = implode(', ', $query->select);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$select = $query->select = '*';
|
||||
}
|
||||
if ($select === '*') {
|
||||
@ -238,8 +239,11 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
protected function isOldMssql()
|
||||
{
|
||||
$pdo = $this->db->getSlavePdo();
|
||||
$version = preg_split("/\./", $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION));
|
||||
return $version[0] < 11;
|
||||
if ($this->_oldMssql === null) {
|
||||
$pdo = $this->db->getSlavePdo();
|
||||
$version = preg_split("/\./", $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION));
|
||||
$this->_oldMssql = $version[0] < 11;
|
||||
}
|
||||
return $this->_oldMssql;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user