summaryrefslogtreecommitdiff
path: root/framework/Db/Schema/mssql/TMssqlPdoAdapter.php
diff options
context:
space:
mode:
authorrojaro <>2009-07-13 14:02:17 +0000
committerrojaro <>2009-07-13 14:02:17 +0000
commit78af2b4630ccde4b03659a259f739f83ae0de9ec (patch)
treef1a27cc2dbe77682143ae8243eee91187e66c6fe /framework/Db/Schema/mssql/TMssqlPdoAdapter.php
parentb4b2c7e5e2eadd48b344538823dcf5645939ba44 (diff)
- ActiveRecord Port from Yii ... not perfect but works ^^
Diffstat (limited to 'framework/Db/Schema/mssql/TMssqlPdoAdapter.php')
-rwxr-xr-xframework/Db/Schema/mssql/TMssqlPdoAdapter.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/framework/Db/Schema/mssql/TMssqlPdoAdapter.php b/framework/Db/Schema/mssql/TMssqlPdoAdapter.php
new file mode 100755
index 00000000..c9d4597f
--- /dev/null
+++ b/framework/Db/Schema/mssql/TMssqlPdoAdapter.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * TMssqlPdo class file
+ *
+ * @author Christophe Boulain <Christophe.Boulain@gmail.com>
+ * @link http://www.yiiframework.com/
+ * @copyright Copyright &copy; 2008-2009 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: TMssqlPdoAdapter.php 2679 2009-06-15 07:49:42Z Christophe.Boulain $
+ * @package system.db.schema.mssql
+ * @since 1.0.4
+ */
+class TMssqlPdoAdapter extends PDO
+{
+ /**
+ * Get the last inserted id value
+ * MSSQL doesn't support sequence, so, argument is ignored
+ *
+ * @param string sequence name. Defaults to null
+ * @return int last inserted id
+ */
+ public function lastInsertId ($sequence=NULL)
+ {
+ return $this->query('SELECT SCOPE_IDENTITY()')->fetchColumn();
+ }
+
+ /**
+ * 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;
+ }
+}