]> granicus.if.org Git - php/commitdiff
Added new function ii_autocommit()
authorHénot David <henot@php.net>
Mon, 17 Jul 2000 23:57:36 +0000 (23:57 +0000)
committerHénot David <henot@php.net>
Mon, 17 Jul 2000 23:57:36 +0000 (23:57 +0000)
ext/ingres_ii/ii.c
ext/ingres_ii/php_ii.h

index dbf42dcc958979b57f19bce034cfde797d68a2ac..cc67e75849b453abbdd7d8b2911362ad1cb7bf47 100644 (file)
@@ -54,6 +54,7 @@ function_entry ii_functions[] = {
   PHP_FE(ii_fetch_object,     NULL)
   PHP_FE(ii_rollback,         NULL)
   PHP_FE(ii_commit,           NULL)
+  PHP_FE(ii_autocommit,       NULL)
   {NULL, NULL, NULL}   /* Must be the last line in ii_functions[] */
 };
 
@@ -1285,5 +1286,43 @@ PHP_FUNCTION(ii_commit)
 }
 /* }}} */
 
+/* {{{ proto bool ii_autocommit([resource link])
+   Switch autocommit on or off */
+PHP_FUNCTION(ii_autocommit)
+{
+  zval **link;
+  int argc;
+  int link_id = -1;
+  II_LINK *ii_link;
+  IIAPI_AUTOPARM autoParm;
+  IILS_FETCH();
+  
+  argc = ZEND_NUM_ARGS();
+  if (argc > 1 || (argc && zend_get_parameters_ex(argc, &link) == FAILURE)){
+    WRONG_PARAM_COUNT;
+  }
+  
+  if (argc == 0) {
+    link_id = IIG(default_link);
+  }
+  ZEND_FETCH_RESOURCE2(ii_link, II_LINK *, link, link_id, "Ingres II Link", le_ii_link, le_ii_plink);
+
+  autoParm.ac_genParm.gp_callback = NULL;
+  autoParm.ac_genParm.gp_closure = NULL;
+  autoParm.ac_connHandle = ii_link->connHandle;
+  autoParm.ac_tranHandle = ii_link->tranHandle;
+
+  IIapi_autocommit(&autoParm);
+  ii_sync(&(autoParm.ac_genParm));
+
+  if(ii_success(&(autoParm.ac_genParm))==II_FAIL) {
+    RETURN_FALSE;
+  }
+  
+  ii_link->tranHandle = autoParm.ac_tranHandle;
+  RETURN_TRUE;
+}
+/* }}} */
+
 #endif /* HAVE_II */
 
index 052cc65297273d06875b0daa1901edac1cbf68e2..2c35e63de5793ec062e70cc2e16da31e46e47bfd 100644 (file)
@@ -55,6 +55,7 @@ PHP_FUNCTION(ii_fetch_row);
 PHP_FUNCTION(ii_fetch_object);
 PHP_FUNCTION(ii_rollback);
 PHP_FUNCTION(ii_commit);
+PHP_FUNCTION(ii_autocommit);
 
 ZEND_BEGIN_MODULE_GLOBALS(ii)
        long allow_persistent;