]> granicus.if.org Git - php/commitdiff
Changed _php_ibase_trans_end() to allow committing of default transaction
authorArd Biesheuvel <abies@php.net>
Fri, 8 Aug 2003 01:42:09 +0000 (01:42 +0000)
committerArd Biesheuvel <abies@php.net>
Fri, 8 Aug 2003 01:42:09 +0000 (01:42 +0000)
of a non-default link

ext/interbase/interbase.c

index b44eda851cea8924eaa29b242b883e76f783d518..bb41d847327b58a1113c783feb7ee1a8aab418de 100644 (file)
@@ -226,7 +226,7 @@ typedef struct {
     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)
 {
@@ -1778,22 +1778,38 @@ static void _php_ibase_trans_end(INTERNAL_FUNCTION_PARAMETERS, int commit)
        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_FUNCTION(ibase_query)
                        _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;