/framework/db/schema/mssql/CMssqlPdoAdapter.php
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
- <?php
- /**
- * CMssqlPdo class file
- *
- * @author Christophe Boulain <Christophe.Boulain@gmail.com>
- * @link http://www.yiiframework.com/
- * @copyright Copyright © 2008-2011 Yii Software LLC
- * @license http://www.yiiframework.com/license/
- */
- /**
- * This is an extension of default PDO class for mssql driver only
- * It provides some missing functionalities of pdo driver
- * @author Christophe Boulain <Christophe.Boulain@gmail.com>
- * @version $Id: CMssqlPdoAdapter.php 3309 2011-06-23 16:59:34Z qiang.xue $
- * @package system.db.schema.mssql
- * @since 1.0.4
- */
- class CMssqlPdoAdapter extends PDO
- {
- /**
- * Get the last inserted id value
- * MSSQL doesn't support sequence, so, argument is ignored
- *
- * @param string|null sequence name. Defaults to null
- * @return integer last inserted id
- */
- public function lastInsertId ($sequence=NULL)
- {
- $value=$this->query('SELECT SCOPE_IDENTITY()')->fetchColumn();
- $value=preg_replace('/[,.]0+$/', '', $value); // issue 2312
- return strtr($value,array(','=>'','.'=>''));
- }
- /**
- * Begin a transaction
- *
- * Is is necessary to override pdo's method, as mssql pdo drivers
- * does not support transaction
- *
- * @return boolean
- */
- public function beginTransaction ()
- {
- $this->exec('BEGIN TRANSACTION');
- return true;
- }
- /**
- * Commit a transaction
- *
- * Is is necessary to override pdo's method, as mssql pdo drivers
- * does not support transaction
- *
- * @return boolean
- */
- public function commit ()
- {
- $this->exec('COMMIT TRANSACTION');
- return true;
- }
- /**
- * Rollback a transaction
- *
- * Is is necessary to override pdo's method, ac mssql pdo drivers
- * does not support transaction
- *
- * @return boolean
- */
- public function rollBack ()
- {
- $this->exec('ROLLBACK TRANSACTION');
- return true;
- }
- }