Skip to content
PHP Ecosystem
Explore

SqlsrvPDO

API reference › yii › db › mssql › SqlsrvPDO

classyii\db\mssql\SqlsrvPDO
ExtendsPDO
Since2.0
Sourceframework/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.

MethodDescriptionDefined by
lastInsertId()Returns value of the last inserted ID.SqlsrvPDO
ConstantValueDescriptionDefined by
SQLSRV_ATTR_ENCODING1000A constant for the pdo_sqlsrv encoding attribute. Pass as a key in Connection::$attributes.SqlsrvPDO
SQLSRV_ENCODING_SYSTEM3A 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_UTF865001A constant for UTF-8 string encoding. This is the pdo_sqlsrv default for PDO::PARAM_STR parameters.SqlsrvPDO
public function lastInsertId(string|null $sequence = null): string|false

Returns value of the last inserted ID.

SQLSRV driver implements PDO::lastInsertId() method but with a single peculiarity:

  • when $sequence value 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

ParameterTypeDescription
$sequencestring|nullThe sequence name. Defaults to null.

Returns

string|false: Last inserted ID value.