Issues

ZF-2319: Support transactions in the pdo_mssql driver in Zend Framework

Issue Type: Improvement Created: 2007-12-16T19:53:06.000+0000 Last Updated: 2008-03-21T16:25:26.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Chris Kings-Lynne (chriskl) Assignee: Thomas Weidner (thomas) Tags: - Zend_Db

Related issues: Attachments:

Description

The PDO driver in PHP for MSSQL unfortunately does not support transactions. However, due to the way that Zend Framework is designed we can support it anyway.

<pre class="highlight">
Index: C:/Development/ibt/portal/trunk/lib/ZendFramework/library/Zend/Db/Adapter/Pdo/Mssql.php
===================================================================
--- C:/Development/ibt/portal/trunk/lib/ZendFramework/library/Zend/Db/Adapter/Pdo/Mssql.php (revision 112)
+++ C:/Development/ibt/portal/trunk/lib/ZendFramework/library/Zend/Db/Adapter/Pdo/Mssql.php (revision 113)
@@ -314,4 +314,41 @@
         return (int)$this->fetchOne($sql);
     }
 
+    /**
+     * Begin a transaction.
+     *
+     * It is necessary to override the abstract PDO transaction functions here, as
+     * the PDO driver for MSSQL does not support transactions.
+     */
+    protected function _beginTransaction()
+    {
+        $this->_connect();
+        $this->_connection->exec('BEGIN TRANSACTION');
+        return true;
+    }
+
+    /**
+     * Commit a transaction.
+     *
+     * It is necessary to override the abstract PDO transaction functions here, as
+     * the PDO driver for MSSQL does not support transactions.
+     */
+    protected function _commit()
+    {
+        $this->_connect();
+        $this->_connection->exec('COMMIT TRANSACTION');
+        return true;
+    }
+
+    /**
+     * Roll-back a transaction.
+     *
+     * It is necessary to override the abstract PDO transaction functions here, as
+     * the PDO driver for MSSQL does not support transactions.
+     */
+    protected function _rollBack() {
+        $this->_connect();
+        $this->_connection->exec('ROLLBACK TRANSACTION');
+        return true;
+    }
 }

Please consider this for future Zend - it's extremely important for those of us who use MSSQL!

Comments

Posted by Thomas Weidner (thomas) on 2008-01-20T06:44:32.000+0000

Integrated in the incubator with some other improvements related to MSSQL in the testbed made by Simon

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts