PageRenderTime 70ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/framework/db/schema/mssql/CMssqlPdoAdapter.php

https://bitbucket.org/dinhtrung/yiicorecms/
PHP | 76 lines | 25 code | 4 blank | 47 comment | 0 complexity | 00a35d7141a346a36856237803afb34e MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, CC0-1.0, BSD-2-Clause, GPL-2.0, LGPL-2.1, LGPL-3.0
  1. <?php
  2. /**
  3. * CMssqlPdo class file
  4. *
  5. * @author Christophe Boulain <Christophe.Boulain@gmail.com>
  6. * @link http://www.yiiframework.com/
  7. * @copyright Copyright &copy; 2008-2011 Yii Software LLC
  8. * @license http://www.yiiframework.com/license/
  9. */
  10. /**
  11. * This is an extension of default PDO class for mssql driver only
  12. * It provides some missing functionalities of pdo driver
  13. * @author Christophe Boulain <Christophe.Boulain@gmail.com>
  14. * @version $Id: CMssqlPdoAdapter.php 3309 2011-06-23 16:59:34Z qiang.xue $
  15. * @package system.db.schema.mssql
  16. * @since 1.0.4
  17. */
  18. class CMssqlPdoAdapter extends PDO
  19. {
  20. /**
  21. * Get the last inserted id value
  22. * MSSQL doesn't support sequence, so, argument is ignored
  23. *
  24. * @param string|null sequence name. Defaults to null
  25. * @return integer last inserted id
  26. */
  27. public function lastInsertId ($sequence=NULL)
  28. {
  29. $value=$this->query('SELECT SCOPE_IDENTITY()')->fetchColumn();
  30. $value=preg_replace('/[,.]0+$/', '', $value); // issue 2312
  31. return strtr($value,array(','=>'','.'=>''));
  32. }
  33. /**
  34. * Begin a transaction
  35. *
  36. * Is is necessary to override pdo's method, as mssql pdo drivers
  37. * does not support transaction
  38. *
  39. * @return boolean
  40. */
  41. public function beginTransaction ()
  42. {
  43. $this->exec('BEGIN TRANSACTION');
  44. return true;
  45. }
  46. /**
  47. * Commit a transaction
  48. *
  49. * Is is necessary to override pdo's method, as mssql pdo drivers
  50. * does not support transaction
  51. *
  52. * @return boolean
  53. */
  54. public function commit ()
  55. {
  56. $this->exec('COMMIT TRANSACTION');
  57. return true;
  58. }
  59. /**
  60. * Rollback a transaction
  61. *
  62. * Is is necessary to override pdo's method, ac mssql pdo drivers
  63. * does not support transaction
  64. *
  65. * @return boolean
  66. */
  67. public function rollBack ()
  68. {
  69. $this->exec('ROLLBACK TRANSACTION');
  70. return true;
  71. }
  72. }