Issue Details (XML | Word | Printable)

Key: ZF-2319
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Thomas Weidner
Reporter: Chris Kings-Lynne
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Support transactions in the pdo_mssql driver in Zend Framework

Created: 16/Dec/07 07:53 PM   Updated: 21/Mar/08 04:25 PM   Resolved: 20/Jan/08 06:44 AM
Return to search "Fixed in 1.5.1"
Component/s: Zend_Db
Affects Version/s: 1.0.3
Fix Version/s: 1.5.0

Time Tracking:
Original Estimate: 10 minutes
Original Estimate - 10 minutes
Remaining Estimate: 10 minutes
Remaining Estimate - 10 minutes
Time Spent: Not Specified
Time Spent - Not Specified

Fix Version Priority: Should Have


 Description  « Hide

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.

diff
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!



Thomas Weidner added a comment - 20/Jan/08 06:44 AM

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