first commit
This commit is contained in:
53
vendor/yiisoft/yii2/db/mssql/DBLibPDO.php
vendored
Normal file
53
vendor/yiisoft/yii2/db/mssql/DBLibPDO.php
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @link https://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license https://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\db\mssql;
|
||||
|
||||
/**
|
||||
* This is an extension of the default PDO class of DBLIB drivers.
|
||||
* It provides workarounds for improperly implemented functionalities of the DBLIB drivers.
|
||||
*
|
||||
* @author Bert Brunekreeft <bbrunekreeft@gmail.com>
|
||||
* @since 2.0.41
|
||||
*/
|
||||
class DBLibPDO extends \PDO
|
||||
{
|
||||
/**
|
||||
* Returns value of the last inserted ID.
|
||||
* @param string|null $name the sequence name. Defaults to null.
|
||||
* @return string|false last inserted ID value.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function lastInsertId($name = null)
|
||||
{
|
||||
return $this->query('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS bigint)')->fetchColumn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param int $attribute One of the PDO::ATTR_* constants.
|
||||
* @return mixed A successful call returns the value of the requested PDO attribute.
|
||||
* An unsuccessful call returns null.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getAttribute($attribute)
|
||||
{
|
||||
try {
|
||||
return parent::getAttribute($attribute);
|
||||
} catch (\PDOException $e) {
|
||||
switch ($attribute) {
|
||||
case self::ATTR_SERVER_VERSION:
|
||||
return $this->query("SELECT CAST(SERVERPROPERTY('productversion') AS VARCHAR)")->fetchColumn();
|
||||
default:
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user