abies           Thu Aug  7 21:42:09 2003 EDT

  Modified files:              
    /php-src/ext/interbase      interbase.c 
  Log:
  Changed _php_ibase_trans_end() to allow committing of default transaction
  of a non-default link
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.120 php-src/ext/interbase/interbase.c:1.121
--- php-src/ext/interbase/interbase.c:1.120     Wed Aug  6 21:00:22 2003
+++ php-src/ext/interbase/interbase.c   Thu Aug  7 21:42:09 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interbase.c,v 1.120 2003/08/07 01:00:22 abies Exp $ */
+/* $Id: interbase.c,v 1.121 2003/08/08 01:42:09 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -226,7 +226,7 @@
     char *tpb_ptr;
 } ISC_TEB;
 
-/* Fill ib_link and trans_n with the correct database link and transaction slot 
number.
+/* Fill ib_link and trans with the correct database link and transaction.
  */
 static void _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAMETERS, zval **link_id, 
ibase_db_link **ib_link, ibase_trans **trans)
 {
@@ -670,7 +670,7 @@
 
        php_info_print_table_start();
        php_info_print_table_row(2, "Interbase Support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.120 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.121 $");
 #ifdef COMPILE_DL_INTERBASE
        php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1778,22 +1778,38 @@
        switch (ZEND_NUM_ARGS()) {
 
                ibase_db_link *ib_link;
-               zval **trans_arg;
+               zval **arg;
 
                case 0:
                        ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, 
IBG(default_link), "InterBase link", le_link, le_plink);
+                       if (ib_link->trans == NULL) {
+                               /* this link doesn't have a default transaction */
+                               _php_ibase_module_error("Default link has no default 
transaction");
+                               RETURN_FALSE;
+                       }
                        trans = ib_link->trans->trans;
                        break;
 
                case 1: 
-                       if (zend_get_parameters_ex(1, &trans_arg) == FAILURE) {
+                       if (zend_get_parameters_ex(1, &arg) == FAILURE) {
                                RETURN_FALSE;
                        }
-                       ZEND_FETCH_RESOURCE(trans, ibase_trans *, trans_arg, -1, 
"InterBase transaction", le_trans);
+                       /* one id was passed, could be db or trans id */
+                       _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
arg, &ib_link, &trans);
+                       if (trans != NULL) {                    
+                               convert_to_long_ex(arg);
+                               res_id = Z_LVAL_PP(arg);
 
-                       convert_to_long_ex(trans_arg);
-                       res_id = Z_LVAL_PP(trans_arg);
+                       } else {
+                               ZEND_FETCH_RESOURCE(ib_link, ibase_db_link *, arg, -1, 
"InterBase transaction", le_trans);
 
+                               if (ib_link->trans == NULL) {
+                                       /* this link doesn't have a default 
transaction */
+                                       _php_ibase_module_error("Link has no default 
transaction");
+                                       RETURN_FALSE;
+                               }
+                               trans = ib_link->trans->trans;
+                       }
                        break;
 
                default:
@@ -1955,8 +1971,7 @@
                        _php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
args[0], &ib_link, &trans);
                        break;  
                case 3:
-                       /* two ids were passed, first should be link and second should 
be trans;
-                       */
+                       /* two ids were passed, first should be link and second should 
be trans; */
                        ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link*, args[0], -1, 
"InterBase link", le_link, le_plink);
                        ZEND_FETCH_RESOURCE(trans, ibase_trans*, args[1], -1, 
"InterBase transaction", le_trans);
                        break;



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

Reply via email to