Class yii\db\mssql\SqlsrvPDO
| Inheritance | yii\ |
|---|---|
| Available since version | 2.0 |
| Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/mssql/SqlsrvPDO.php |
This is an extension of the default PDO class of SQLSRV driver.
It provides workarounds for improperly implemented functionalities of the SQLSRV driver.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| lastInsertId() | Returns value of the last inserted ID. | yii\ |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| SQLSRV_ATTR_ENCODING | 1000 |
A constant for the pdo_sqlsrv encoding attribute. Pass as a key in yii\ |
yii\ |
| SQLSRV_ENCODING_SYSTEM | 3 |
A constant for ANSI (system code page) string encoding. Use with SQLSRV_ATTR_ENCODING to avoid the implicit
nvarchar-to-varchar conversion that degrades performance on char/varchar indexed columns.
|
yii\ |
| SQLSRV_ENCODING_UTF8 | 65001 | A constant for UTF-8 string encoding. This is the pdo_sqlsrv default for PDO::PARAM_STR parameters. | yii\ |
Method Details
Returns value of the last inserted ID.
SQLSRV driver implements yii\
- when
$sequencevalue is a null or an empty string it returns an empty string. - but when parameter is not specified it works as expected and returns actual
- last inserted ID (like the other PDO drivers).
| public string|false lastInsertId ( string|null $sequence = null ) | ||
| $sequence | string|null |
The sequence name. Defaults to |
| return | string|false |
Last inserted ID value. |
|---|---|---|
public function lastInsertId(string|null $sequence = null): string|false
{
if ($sequence === null || $sequence === '') {
return parent::lastInsertId();
}
return parent::lastInsertId($sequence);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.