SqlsrvPDO
API reference › yii › db › mssql › SqlsrvPDO
This is an extension of the default PDO class of SQLSRV driver.
It provides workarounds for improperly implemented functionalities of the SQLSRV driver.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
lastInsertId() | Returns value of the last inserted ID. | SqlsrvPDO |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
SQLSRV_ATTR_ENCODING | 1000 | A constant for the pdo_sqlsrv encoding attribute. Pass as a key in Connection::$attributes. | SqlsrvPDO |
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. | SqlsrvPDO |
SQLSRV_ENCODING_UTF8 | 65001 | A constant for UTF-8 string encoding. This is the pdo_sqlsrv default for PDO::PARAM_STR parameters. | SqlsrvPDO |
Method details
Section titled “Method details”lastInsertId()
Section titled “lastInsertId() ”public function lastInsertId(string|null $sequence = null): string|falseReturns value of the last inserted ID.
SQLSRV driver implements PDO::lastInsertId() method but with a single peculiarity:
- 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).
Parameters
| Parameter | Type | Description |
|---|---|---|
$sequence | string| | The sequence name. Defaults to null. |
Returns
string|false: Last inserted ID value.