wez             Sat Jun 11 08:38:12 2005 EDT

  Modified files:              
    /php-src/ext/pdo_odbc       odbc_driver.c 
  Log:
  Fix for PECL #3714: beginTransaction doesn't work if you're in auto-commit 
mode.
  
  
http://cvs.php.net/diff.php/php-src/ext/pdo_odbc/odbc_driver.c?r1=1.21&r2=1.22&ty=u
Index: php-src/ext/pdo_odbc/odbc_driver.c
diff -u php-src/ext/pdo_odbc/odbc_driver.c:1.21 
php-src/ext/pdo_odbc/odbc_driver.c:1.22
--- php-src/ext/pdo_odbc/odbc_driver.c:1.21     Sun Feb  6 12:49:48 2005
+++ php-src/ext/pdo_odbc/odbc_driver.c  Sat Jun 11 08:38:12 2005
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: odbc_driver.c,v 1.21 2005/02/06 17:49:48 wez Exp $ */
+/* $Id: odbc_driver.c,v 1.22 2005/06/11 12:38:12 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -218,7 +218,17 @@
 
 static int odbc_handle_begin(pdo_dbh_t *dbh TSRMLS_DC)
 {
-       /* with ODBC, there is nothing special to be done */
+       if (dbh->auto_commit) {
+               /* we need to disable auto-commit now, to be able to initiate a 
transaction */
+               RETCODE rc;
+               pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
+
+               rc = SQLSetConnectAttr(H->dbc, SQL_ATTR_AUTOCOMMIT, 
(SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_NTS);
+               if (rc != SQL_SUCCESS) {
+                       pdo_odbc_drv_error("SQLSetConnectAttr AUTOCOMMIT = 
OFF");
+                       return 0;
+               }
+       }
        return 1;
 }
 
@@ -236,6 +246,16 @@
                        return 0;
                }
        }
+
+       if (dbh->auto_commit) {
+               /* turn auto-commit back on again */
+               RETCODE rc;
+               rc = SQLSetConnectAttr(H->dbc, SQL_ATTR_AUTOCOMMIT, 
(SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_NTS);
+               if (rc != SQL_SUCCESS) {
+                       pdo_odbc_drv_error("SQLSetConnectAttr AUTOCOMMIT = 
OFF");
+                       return 0;
+               }
+       }
        return 1;
 }
 
@@ -253,6 +273,16 @@
                        return 0;
                }
        }
+       if (dbh->auto_commit && H->dbc && dbh->in_txn) {
+               /* turn auto-commit back on again */
+               RETCODE rc;
+               rc = SQLSetConnectAttr(H->dbc, SQL_ATTR_AUTOCOMMIT, 
(SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_NTS);
+               if (rc != SQL_SUCCESS) {
+                       pdo_odbc_drv_error("SQLSetConnectAttr AUTOCOMMIT = 
OFF");
+                       return 0;
+               }
+       }
+
        return 1;
 }
 
@@ -328,7 +358,7 @@
        }
 
        if (!dbh->auto_commit) {
-               rc = SQLSetConnectAttr(H->dbc, SQL_ATTR_AUTOCOMMIT, 
SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER);
+               rc = SQLSetConnectAttr(H->dbc, SQL_ATTR_AUTOCOMMIT, 
(SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_NTS);
                if (rc != SQL_SUCCESS) {
                        pdo_odbc_drv_error("SQLSetConnectAttr AUTOCOMMIT = 
OFF");
                        odbc_handle_closer(dbh TSRMLS_CC);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to