1: <?php
2: /**
3: * CMssqlSqlsrvPdoAdapter class file.
4: *
5: * @author Timur Ruziev <resurtm@gmail.com>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11: /**
12: * This is an extension of default PDO class for MSSQL SQLSRV driver only.
13: * It provides workaround of the improperly implemented functionalities of PDO SQLSRV driver.
14: *
15: * @author Timur Ruziev <resurtm@gmail.com>
16: * @package system.db.schema.mssql
17: * @since 1.1.13
18: */
19: class CMssqlSqlsrvPdoAdapter extends PDO
20: {
21: /**
22: * Returns last inserted ID value.
23: * SQLSRV driver supports PDO::lastInsertId() with one peculiarity: when $sequence's value is null or empty
24: * string it returns empty string. But when parameter is not specified at all it's working as expected
25: * and returns actual last inserted ID (like other PDO drivers).
26: *
27: * @param string|null $sequence the sequence name. Defaults to null.
28: * @return integer last inserted ID value.
29: */
30: public function lastInsertId($sequence=null)
31: {
32: if(!$sequence)
33: return parent::lastInsertId();
34: return parent::lastInsertId($sequence);
35: }
36: }
37: