CMssqlSqlsrvPdoAdapter.php 1.1 KB

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