1: <?php
2: /**
3: * CMssqlPdo class file
4: *
5: * @author Christophe Boulain <Christophe.Boulain@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 driver only
13: * It provides some missing functionalities of pdo driver
14: * @author Christophe Boulain <Christophe.Boulain@gmail.com>
15: * @package system.db.schema.mssql
16: */
17: class CMssqlPdoAdapter extends PDO
18: {
19: /**
20: * Get the last inserted id value
21: * MSSQL doesn't support sequence, so, argument is ignored
22: *
23: * @param string|null sequence name. Defaults to null
24: * @return integer last inserted id
25: */
26: public function lastInsertId ($sequence=NULL)
27: {
28: return $this->query('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS bigint)')->fetchColumn();
29: }
30:
31: /**
32: * Begin a transaction
33: *
34: * Is is necessary to override pdo's method, as mssql pdo drivers
35: * does not support transaction
36: *
37: * @return boolean
38: */
39: public function beginTransaction ()
40: {
41: $this->exec('BEGIN TRANSACTION');
42: return true;
43: }
44:
45: /**
46: * Commit a transaction
47: *
48: * Is is necessary to override pdo's method, as mssql pdo drivers
49: * does not support transaction
50: *
51: * @return boolean
52: */
53: public function commit ()
54: {
55: $this->exec('COMMIT TRANSACTION');
56: return true;
57: }
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: }
73: