# DBLibPDO

> This is an extension of the default PDO class of DBLIB drivers.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [db](/docs/api/yii/db/index.md) › [mssql](/docs/api/yii/db/mssql/index.md) › DBLibPDO

| class | `yii\db\mssql\DBLibPDO` |
| --- | --- |
| Extends | [`PDO`](https://www.php.net/manual/en/class.pdo.php) |
| Since | 2.0.41 |
| Source | [`framework/db/mssql/DBLibPDO.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/db/mssql/DBLibPDO.php#L23) |

This is an extension of the default PDO class of DBLIB drivers.

It provides workarounds for improperly implemented functionalities of the DBLIB drivers.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`getAttribute()`](#method-getAttribute) | Retrieve a database connection attribute. | `DBLibPDO` |
| [`lastInsertId()`](#method-lastInsertId) | Returns value of the last inserted ID. | `DBLibPDO` |

## Method details

### getAttribute() <span id="method-getAttribute"></span>

```php
public function getAttribute(int $attribute): mixed
```

Retrieve a database connection attribute.

It is necessary to override PDO's method as some MSSQL PDO driver (for example, dblib) does not support getting
attributes.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$attribute` | `int` | One of the PDO::ATTR_* constants. |

**Returns**

`mixed`: A successful call returns the value of the requested PDO attribute. An unsuccessful call returns `null`.

### lastInsertId() <span id="method-lastInsertId"></span>

```php
public function lastInsertId(string|null $name = null): string|false
```

Returns value of the last inserted ID.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string\|null` | The sequence name. Defaults to null. |

**Returns**

`string|false`: Last inserted ID value.