Zend Framework

Support transactions in the pdo_mssql driver in Zend Framework

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.3
  • Fix Version/s: 1.5.0
  • Component/s: Zend_Db
  • Labels:
    None
  • Fix Version Priority:
    Should Have

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.

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!

Activity

Hide
Thomas Weidner added a comment -

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

Show
Thomas Weidner added a comment - Integrated in the incubator with some other improvements related to MSSQL in the testbed made by Simon

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
10m
Original Estimate - 10 minutes
Remaining:
10m
Remaining Estimate - 10 minutes
Logged:
Not Specified
Time Spent - Not Specified