abies           Wed Aug  6 13:51:46 2003 EDT

  Modified files:              
    /php-src/ext/interbase      interbase.c php_interbase.h 
  Log:
  Added three new user functions
  
  ibase_{commit|rollback}_ret()
  Commit or rollback a transaction without losing the transaction context.
  
  ibase_name_result()
  Assign a name to a result so {UPDATE|DELETE} ... WHERE CURRENT OF <name>
  statements can be used.
  
  
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.117 php-src/ext/interbase/interbase.c:1.118
--- php-src/ext/interbase/interbase.c:1.117     Wed Aug  6 11:27:16 2003
+++ php-src/ext/interbase/interbase.c   Wed Aug  6 13:51:46 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interbase.c,v 1.117 2003/08/06 15:27:16 abies Exp $ */
+/* $Id: interbase.c,v 1.118 2003/08/06 17:51:46 abies Exp $ */
 
 
 /* TODO: Arrays, roles?
@@ -75,8 +75,8 @@
 #endif
 
 #ifdef ZEND_DEBUG
-#define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__);
-/* #define IBDEBUG(a)*/
+/* #define IBDEBUG(a) php_printf("::: %s (%d)\n", a, __LINE__); */
+#define IBDEBUG(a)
 #else
 #define IBDEBUG(a)
 #endif
@@ -94,6 +94,7 @@
        PHP_FE(ibase_fetch_assoc, NULL)
        PHP_FE(ibase_fetch_object, NULL)
        PHP_FE(ibase_free_result, NULL)
+       PHP_FE(ibase_name_result, NULL)
        PHP_FE(ibase_prepare, NULL)
        PHP_FE(ibase_execute, NULL)
        PHP_FE(ibase_free_query, NULL)
@@ -107,6 +108,8 @@
        PHP_FE(ibase_trans, NULL)
        PHP_FE(ibase_commit, NULL)
        PHP_FE(ibase_rollback, NULL)
+       PHP_FE(ibase_commit_ret, NULL)
+       PHP_FE(ibase_rollback_ret, NULL)
 
        PHP_FE(ibase_blob_info, NULL)
        PHP_FE(ibase_blob_create, NULL)
@@ -674,7 +677,7 @@
 
        php_info_print_table_start();
        php_info_print_table_row(2, "Interbase Support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.117 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.118 $");
 #ifdef COMPILE_DL_INTERBASE
        php_info_print_table_row(2, "Dynamic Module", "Yes");
 #endif
@@ -1767,12 +1770,15 @@
 /* }}} */
 
 /* {{{ _php_ibase_trans_end() */
+#define RETAIN 2
 #define COMMIT 1
 #define ROLLBACK 0
+
 static void _php_ibase_trans_end(INTERNAL_FUNCTION_PARAMETERS, int commit)
 {
        ibase_trans *trans = NULL;
        int res_id = 0;
+       ISC_STATUS result;
 
        RESET_ERRMSG;
 
@@ -1802,20 +1808,29 @@
                        break;
        }
 
-       if (commit) {
-               if (isc_commit_transaction(IB_STATUS, &trans->handle)) {
-                       _php_ibase_error(TSRMLS_C);
-                       RETURN_FALSE;
-               }
-       } else {
-               if (isc_rollback_transaction(IB_STATUS, &trans->handle)) {
-                       _php_ibase_error(TSRMLS_C);
-                       RETURN_FALSE;
-               }
+       switch (commit) {
+               
+               case ROLLBACK:
+                       result = isc_rollback_transaction(IB_STATUS, &trans->handle);
+                       break;
+               case COMMIT:
+                       result = isc_commit_transaction(IB_STATUS, &trans->handle);
+                       break;
+               case (ROLLBACK | RETAIN):
+                       result = isc_rollback_retaining(IB_STATUS, &trans->handle);
+                       break;
+               case (COMMIT | RETAIN):
+                       result = isc_commit_retaining(IB_STATUS, &trans->handle);
+                       break;
        }
        
+       if (result) {
+               _php_ibase_error(TSRMLS_C);
+               RETURN_FALSE;
+       }
+
        /* Don't try to destroy implicitly opened transaction from list... */
-       if (res_id != 0) {
+       if ( (commit & RETAIN) == 0 && res_id != 0) {
                zend_list_delete(res_id);
        }
        RETURN_TRUE;
@@ -1838,6 +1853,22 @@
 }
 /* }}} */
 
+/* {{{ proto bool ibase_commit_ret( resource link_identifier )
+   Commit transaction and retain the transaction context */
+PHP_FUNCTION(ibase_commit_ret)
+{
+       _php_ibase_trans_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, COMMIT | RETAIN);
+}
+/* }}} */
+
+/* {{{ proto bool ibase_rollback_ret( resource link_identifier )
+   Rollback transaction and retain the transaction context */
+PHP_FUNCTION(ibase_rollback_ret)
+{
+       _php_ibase_trans_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, ROLLBACK | RETAIN);
+}
+/* }}} */
+
 /* {{{ proto resource ibase_query([resource link_identifier [, string query [, int 
bind_args]]])
    Execute a query */
 PHP_FUNCTION(ibase_query)
@@ -2437,6 +2468,32 @@
 }
 /* }}} */
 
+
+/* {{{ proto bool ibase_name_result(resource result, string name)
+   Assign a name to a result for use with ... WHERE CURRENT OF <name> statements */
+PHP_FUNCTION(ibase_name_result)
+{
+       zval **result_arg, **name_arg;
+       ibase_result *ib_result;
+
+       RESET_ERRMSG;
+       
+       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &result_arg, &name_arg) 
== FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       ZEND_FETCH_RESOURCE(ib_result, ibase_result *, result_arg, -1, "InterBase 
result", le_result);
+       convert_to_string_ex(name_arg);
+       
+       if (isc_dsql_set_cursor_name(IB_STATUS, &ib_result->stmt, 
Z_STRVAL_PP(name_arg), 0)) {
+               _php_ibase_error(TSRMLS_C);
+               RETURN_FALSE;
+       }
+       RETURN_TRUE;
+}
+/* }}} */
+
+
 /* {{{ proto bool ibase_free_result(resource result)
    Free the memory used by a result */
 PHP_FUNCTION(ibase_free_result)
@@ -2548,8 +2605,11 @@
        }
 
        if (_php_ibase_exec(&ib_result, ib_query, ZEND_NUM_ARGS() - 1, bind_args 
TSRMLS_CC) == FAILURE) {
+               free_alloca(args);
                RETURN_FALSE;
        }
+
+       free_alloca(args);
        
        if (ib_result) { /* select statement */
                ib_query->cursor_open = 1;
Index: php-src/ext/interbase/php_interbase.h
diff -u php-src/ext/interbase/php_interbase.h:1.37 
php-src/ext/interbase/php_interbase.h:1.38
--- php-src/ext/interbase/php_interbase.h:1.37  Wed Aug  6 08:09:30 2003
+++ php-src/ext/interbase/php_interbase.h       Wed Aug  6 13:51:46 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_interbase.h,v 1.37 2003/08/06 12:09:30 abies Exp $ */
+/* $Id: php_interbase.h,v 1.38 2003/08/06 17:51:46 abies Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -29,7 +29,7 @@
 extern zend_module_entry ibase_module_entry;
 #define phpext_interbase_ptr &ibase_module_entry
 
-#ifndef ISC_INT64_FORMAT
+#ifndef ISC_INT64_FORMAT
 #ifdef PHP_WIN32
 #define ISC_INT64_FORMAT "I64"
 #else
@@ -52,6 +52,7 @@
 PHP_FUNCTION(ibase_fetch_assoc);
 PHP_FUNCTION(ibase_fetch_object);
 PHP_FUNCTION(ibase_free_result);
+PHP_FUNCTION(ibase_name_result);
 PHP_FUNCTION(ibase_prepare);
 PHP_FUNCTION(ibase_execute);
 PHP_FUNCTION(ibase_free_query);
@@ -65,6 +66,8 @@
 PHP_FUNCTION(ibase_trans);
 PHP_FUNCTION(ibase_commit);
 PHP_FUNCTION(ibase_rollback);
+PHP_FUNCTION(ibase_commit_ret);
+PHP_FUNCTION(ibase_rollback_ret);
 
 PHP_FUNCTION(ibase_blob_create);
 PHP_FUNCTION(ibase_blob_add);



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

Reply via email to