]> granicus.if.org Git - php/commitdiff
whitespace, braces, coding style (Mc)
authorMarc Boeren <mboeren@php.net>
Fri, 17 Aug 2001 13:56:29 +0000 (13:56 +0000)
committerMarc Boeren <mboeren@php.net>
Fri, 17 Aug 2001 13:56:29 +0000 (13:56 +0000)
15 files changed:
ext/dbx/dbx.c
ext/dbx/dbx.h
ext/dbx/dbx_fbsql.c
ext/dbx/dbx_fbsql.h
ext/dbx/dbx_mssql.c
ext/dbx/dbx_mssql.h
ext/dbx/dbx_mysql.c
ext/dbx/dbx_mysql.h
ext/dbx/dbx_oci8.c
ext/dbx/dbx_oci8.h
ext/dbx/dbx_odbc.c
ext/dbx/dbx_odbc.h
ext/dbx/dbx_pgsql.c
ext/dbx/dbx_pgsql.h
ext/dbx/php_dbx.h

index a394c153b0d7d53b8aeb40f801e3bd0a27b2439b..61c5bb292d0f041a40ef1c570c470e798e51917c 100644 (file)
 #include "dbx_oci8.h"
 
 /* support routines */
-int module_exists(char * module_name) {
-    zend_module_entry * zme;
-    int r;
-    r = zend_hash_find(&module_registry, module_name, strlen(module_name)+1, (void **) &zme);
-    return r==0?1:0;
-    }
-
-int module_identifier_exists(long module_identifier) {
-    switch (module_identifier) {
-        case DBX_MYSQL: return module_exists("mysql");
-        case DBX_ODBC: return module_exists("odbc");
-        case DBX_PGSQL: return module_exists("pgsql");
-        case DBX_MSSQL: return module_exists("mssql");
-        case DBX_FBSQL: return module_exists("fbsql");
-        case DBX_OCI8: return module_exists("oci8");
-        }
-    return 0;
-    }
-
-int get_module_identifier(char * module_name) {
-    if (!strcmp("mysql", module_name)) return DBX_MYSQL;
-    if (!strcmp("odbc", module_name)) return DBX_ODBC;
-    if (!strcmp("pgsql", module_name)) return DBX_PGSQL;
-    if (!strcmp("mssql", module_name)) return DBX_MSSQL;
-    if (!strcmp("fbsql", module_name)) return DBX_FBSQL;
-    if (!strcmp("oci8", module_name)) return DBX_OCI8;
-    return DBX_UNKNOWN;
-    }
-
-int split_dbx_handle_object(zval **dbx_object, zval *** pdbx_handle, zval *** pdbx_module, zval *** pdbx_database) {
-    convert_to_object_ex(dbx_object);
-    if (zend_hash_find(Z_OBJPROP_PP(dbx_object), "handle", 7, (void **) pdbx_handle)==FAILURE
-    || zend_hash_find(Z_OBJPROP_PP(dbx_object), "module", 7, (void **) pdbx_module)==FAILURE
-    || zend_hash_find(Z_OBJPROP_PP(dbx_object), "database", 9, (void **) pdbx_database)==FAILURE) {
-        return 0;
-        }
-    return 1;
-    }
+int module_exists(char *module_name)
+{
+       zend_module_entry *zme;
+       int r;
+       r = zend_hash_find(&module_registry, module_name, strlen(module_name)+1, (void **) &zme);
+       return r==0?1:0;
+}
+
+int module_identifier_exists(long module_identifier)
+{
+       switch (module_identifier) {
+               case DBX_MYSQL: return module_exists("mysql");
+               case DBX_ODBC: return module_exists("odbc");
+               case DBX_PGSQL: return module_exists("pgsql");
+               case DBX_MSSQL: return module_exists("mssql");
+               case DBX_FBSQL: return module_exists("fbsql");
+               case DBX_OCI8: return module_exists("oci8");
+       }
+       return 0;
+}
+
+int get_module_identifier(char *module_name)
+{
+       if (!strcmp("mysql", module_name)) return DBX_MYSQL;
+       if (!strcmp("odbc", module_name)) return DBX_ODBC;
+       if (!strcmp("pgsql", module_name)) return DBX_PGSQL;
+       if (!strcmp("mssql", module_name)) return DBX_MSSQL;
+       if (!strcmp("fbsql", module_name)) return DBX_FBSQL;
+       if (!strcmp("oci8", module_name)) return DBX_OCI8;
+       return DBX_UNKNOWN;
+}
+
+int split_dbx_handle_object(zval **dbx_object, zval ***pdbx_handle, zval ***pdbx_module, zval ***pdbx_database)
+{
+       convert_to_object_ex(dbx_object);
+       if (zend_hash_find(Z_OBJPROP_PP(dbx_object), "handle", 7, (void **) pdbx_handle)==FAILURE
+       || zend_hash_find(Z_OBJPROP_PP(dbx_object), "module", 7, (void **) pdbx_module)==FAILURE
+       || zend_hash_find(Z_OBJPROP_PP(dbx_object), "database", 9, (void **) pdbx_database)==FAILURE) {
+               return 0;
+       }
+       return 1;
+}
 
 /* from dbx.h, to be used in support-files (dbx_mysql.c etc...) */
-void dbx_call_any_function(INTERNAL_FUNCTION_PARAMETERS, char * function_name, zval **returnvalue, int number_of_arguments, zval ***params)
+void dbx_call_any_function(INTERNAL_FUNCTION_PARAMETERS, char *function_name, zval **returnvalue, int number_of_arguments, zval ***params)
 {
-    zval * zval_function_name;
-
-    MAKE_STD_ZVAL(zval_function_name);
-    ZVAL_STRING(zval_function_name, function_name, 1);
-    if (call_user_function_ex(EG(function_table), NULL, zval_function_name, returnvalue, number_of_arguments, params, 0, NULL TSRMLS_CC) == FAILURE) {
-        zend_error(E_ERROR, "function '%s' not found", zval_function_name->value.str.val);
-    }
-    zval_dtor(zval_function_name); /* to free stringvalue memory */
-    FREE_ZVAL(zval_function_name);
+       zval *zval_function_name;
+
+       MAKE_STD_ZVAL(zval_function_name);
+       ZVAL_STRING(zval_function_name, function_name, 1);
+       if (call_user_function_ex(EG(function_table), NULL, zval_function_name, returnvalue, number_of_arguments, params, 0, NULL TSRMLS_CC) == FAILURE) {
+               zend_error(E_ERROR, "function '%s' not found", zval_function_name->value.str.val);
+       }
+       zval_dtor(zval_function_name); /* to free stringvalue memory */
+       FREE_ZVAL(zval_function_name);
 }
 
 /* switch_dbx functions declarations
  * each must be supported in the dbx_module files as dbx_module_function,
  *   e.g. switch_dbx_connect expects a dbx_mysql_connect in de dbx_mysql files
  *   all params except the dbx_module param are passed on
- * each must return the expected zval * 's in the rv parameter, which are passed on unmodified
+ * each must return the expected zval *'s in the rv parameter, which are passed on unmodified
  * do NOT use the return_value parameter from INTERNAL_FUNCTION_PARAMETERS
  * you can additionally return 0 or 1 for failure or success which will also be returned by the switches
  */
 int switch_dbx_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int switch_dbx_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
 int switch_dbx_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int switch_dbx_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns 1 as long or result identifier as resource on success or 0 as long on failure */
+       /* returns 1 as long or result identifier as resource on success or 0 as long on failure */
 int switch_dbx_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int switch_dbx_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int switch_dbx_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int switch_dbx_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int switch_dbx_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module);
-    /* returns string */
+       /* returns string */
 
 /* Every user visible function must have an entry in dbx_functions[].
 */
 function_entry dbx_functions[] = {
-    ZEND_FE(dbx_connect,       NULL)
-    ZEND_FE(dbx_close,         NULL)
-    ZEND_FE(dbx_query,         NULL)
-    ZEND_FE(dbx_error,     NULL)
+       ZEND_FE(dbx_connect,    NULL)
+       ZEND_FE(dbx_close,              NULL)
+       ZEND_FE(dbx_query,              NULL)
+       ZEND_FE(dbx_error,              NULL)
 
-    ZEND_FE(dbx_sort,    NULL)
-    ZEND_FE(dbx_compare,    NULL)
+       ZEND_FE(dbx_sort,               NULL)
+       ZEND_FE(dbx_compare,    NULL)
 
-       {NULL, NULL, NULL}      /* Must be the last line in dbx_functions[] */
-    };
+       {NULL, NULL, NULL} /* Must be the last line in dbx_functions[] */
+};
 
 zend_module_entry dbx_module_entry = {
        "dbx",
-    dbx_functions,
-    ZEND_MINIT(dbx),
-    ZEND_MSHUTDOWN(dbx),
-    NULL, /*ZEND_RINIT(dbx),           /* Replace with NULL if there's nothing to do at request start */
-       NULL, /*ZEND_RSHUTDOWN(dbx),    /* Replace with NULL if there's nothing to do at request end */
+       dbx_functions,
+       ZEND_MINIT(dbx),
+       ZEND_MSHUTDOWN(dbx),
+       NULL, /*ZEND_RINIT(dbx),        /* Replace with NULL if there's nothing to do at request start */
+       NULL, /*ZEND_RSHUTDOWN(dbx),    /* Replace with NULL if there's nothing to do at request end */
        ZEND_MINFO(dbx),
        STANDARD_MODULE_PROPERTIES
-    };
+};
 
 #ifdef COMPILE_DL_DBX
 ZEND_GET_MODULE(dbx)
@@ -160,33 +164,33 @@ ZEND_GET_MODULE(dbx)
 
 ZEND_MINIT_FUNCTION(dbx)
 {
-    REGISTER_LONG_CONSTANT("DBX_MYSQL", DBX_MYSQL, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_ODBC", DBX_ODBC, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_PGSQL", DBX_PGSQL, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_MSSQL", DBX_MSSQL, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_FBSQL", DBX_FBSQL, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_OCI8", DBX_OCI8, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_MYSQL", DBX_MYSQL, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_ODBC", DBX_ODBC, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_PGSQL", DBX_PGSQL, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_MSSQL", DBX_MSSQL, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_FBSQL", DBX_FBSQL, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_OCI8", DBX_OCI8, CONST_CS | CONST_PERSISTENT);
 
-    REGISTER_LONG_CONSTANT("DBX_PERSISTENT", DBX_PERSISTENT, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_PERSISTENT", DBX_PERSISTENT, CONST_CS | CONST_PERSISTENT);
 
-    REGISTER_LONG_CONSTANT("DBX_RESULT_INFO", DBX_RESULT_INFO, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_RESULT_INDEX", DBX_RESULT_INDEX, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_RESULT_ASSOC", DBX_RESULT_ASSOC, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_RESULT_INFO", DBX_RESULT_INFO, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_RESULT_INDEX", DBX_RESULT_INDEX, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_RESULT_ASSOC", DBX_RESULT_ASSOC, CONST_CS | CONST_PERSISTENT);
 
-    REGISTER_LONG_CONSTANT("DBX_CMP_NATIVE", DBX_CMP_NATIVE, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_CMP_TEXT", DBX_CMP_TEXT, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_CMP_NUMBER", DBX_CMP_NUMBER, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_CMP_ASC", DBX_CMP_ASC, CONST_CS | CONST_PERSISTENT);
-    REGISTER_LONG_CONSTANT("DBX_CMP_DESC", DBX_CMP_DESC, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_CMP_NATIVE", DBX_CMP_NATIVE, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_CMP_TEXT", DBX_CMP_TEXT, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_CMP_NUMBER", DBX_CMP_NUMBER, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_CMP_ASC", DBX_CMP_ASC, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("DBX_CMP_DESC", DBX_CMP_DESC, CONST_CS | CONST_PERSISTENT);
 
-    return SUCCESS;
-    }
+       return SUCCESS;
+}
 
 ZEND_MSHUTDOWN_FUNCTION(dbx)
 {
        return SUCCESS;
 }
-    
+
 /* Remove if there's nothing to do at request start */
 /*ZEND_RINIT_FUNCTION(dbx)
 {      return SUCCESS;
@@ -194,21 +198,21 @@ ZEND_MSHUTDOWN_FUNCTION(dbx)
 
 /* Remove if there's nothing to do at request end */
 /*ZEND_RSHUTDOWN_FUNCTION(dbx)
-{   return SUCCESS;
+{      return SUCCESS;
 }*/
 
 ZEND_MINFO_FUNCTION(dbx)
 {
-    php_info_print_table_start();
-    php_info_print_table_row(2, "dbx support", "enabled");
-    php_info_print_table_row(2, "dbx version", "1.0.0");
-    php_info_print_table_row(2, "supported databases", "MySQL<br />ODBC<br />PostgreSQL<br />Microsoft SQL Server<br />FrontBase<br />Oracle 8");
-    php_info_print_table_end();
+       php_info_print_table_start();
+       php_info_print_table_row(2, "dbx support", "enabled");
+       php_info_print_table_row(2, "dbx version", "1.0.0");
+       php_info_print_table_row(2, "supported databases", "MySQL<br />ODBC<br />PostgreSQL<br />Microsoft SQL Server<br />FrontBase<br />Oracle 8");
+       php_info_print_table_end();
 }
 
 /*
 
-    actual implementation of the dbx functions
+       actual implementation of the dbx functions
 
 */
 
@@ -218,80 +222,78 @@ ZEND_MINFO_FUNCTION(dbx)
 */
 ZEND_FUNCTION(dbx_connect)
 {
-    int number_of_arguments=5;
-    zval **arguments[6];
+       int number_of_arguments=5;
+       zval **arguments[6];
 
-    int result;
-    long module_identifier;
-    zval * dbx_module;
-    zval * db_name;
-    zval * rv_dbx_handle;
-    int persistent=0;
+       int result;
+       long module_identifier;
+       zval *dbx_module;
+       zval *db_name;
+       zval *rv_dbx_handle;
+       int persistent=0;
 
-    if ( !(ZEND_NUM_ARGS()==number_of_arguments+1 || ZEND_NUM_ARGS()==number_of_arguments) || zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
+       if ( !(ZEND_NUM_ARGS()==number_of_arguments+1 || ZEND_NUM_ARGS()==number_of_arguments) || zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
                WRONG_PARAM_COUNT;
-       }
-    if (ZEND_NUM_ARGS()==number_of_arguments+1) {
-        convert_to_long_ex(arguments[5]);
-        if ((*arguments[5])->value.lval!=0) persistent=1;
-        }
-
-    if ((*arguments[0])->type == IS_LONG) {
-        if (!module_identifier_exists((*arguments[0])->value.lval)) {
-            zend_error(E_WARNING, "dbx: module '%ld' not loaded or not supported.\n", (*arguments[0])->value.lval);
-            return;
-            }
-        module_identifier = (*arguments[0])->value.lval;
-        }
-    else {
-        convert_to_string_ex(arguments[0]);
-        if (!module_exists((*arguments[0])->value.str.val)) {
-            zend_error(E_WARNING, "dbx: module '%s' not loaded.\n", (*arguments[0])->value.str.val);
-            return;
-            }
-        module_identifier=get_module_identifier((*arguments[0])->value.str.val);
-        if (!module_identifier) {
-            zend_error(E_WARNING, "dbx: unsupported module '%s'.\n", (*arguments[0])->value.str.val);
-            return;
-            }
-        }
-
-    MAKE_STD_ZVAL(dbx_module); 
-    ZVAL_LONG(dbx_module, module_identifier);
-    MAKE_STD_ZVAL(rv_dbx_handle); 
-    ZVAL_LONG(rv_dbx_handle, 0);
-    convert_to_string_ex(arguments[1]);
-    convert_to_string_ex(arguments[2]);
-    convert_to_string_ex(arguments[3]);
-    convert_to_string_ex(arguments[4]);
-    MAKE_STD_ZVAL(db_name); 
-    ZVAL_STRING(db_name, (*arguments[2])->value.str.val, 1);
-    if (persistent) {
-        result = switch_dbx_pconnect(&rv_dbx_handle, arguments[1], arguments[2], arguments[3], arguments[4], INTERNAL_FUNCTION_PARAM_PASSTHRU, &dbx_module);
-        }
-    else {
-        result = switch_dbx_connect(&rv_dbx_handle, arguments[1], arguments[2], arguments[3], arguments[4], INTERNAL_FUNCTION_PARAM_PASSTHRU, &dbx_module);
-        }
-    if (!result) {
-        FREE_ZVAL(dbx_module);
-        zval_dtor(db_name); /* to free stringvalue memory */
-        FREE_ZVAL(db_name);
-        FREE_ZVAL(rv_dbx_handle);
-        RETURN_LONG(0);
-        }
-
-    if (object_init(return_value) != SUCCESS) {
-        zend_error(E_ERROR, "dbx: unable to create resulting object...");
-        FREE_ZVAL(dbx_module);
-        zval_dtor(db_name); /* to free stringvalue memory */
-        FREE_ZVAL(db_name);
-        FREE_ZVAL(rv_dbx_handle);
-        RETURN_LONG(0);
-        }
-
-    zend_hash_update(Z_OBJPROP_P(return_value), "handle", 7, (void *)&(rv_dbx_handle), sizeof(zval *), NULL);
-    zend_hash_update(Z_OBJPROP_P(return_value), "module", 7, (void *)&(dbx_module), sizeof(zval *), NULL);
-    zend_hash_update(Z_OBJPROP_P(return_value), "database", 9, (void *)&(db_name), sizeof(zval *), NULL);
+       }
+       if (ZEND_NUM_ARGS()==number_of_arguments+1) {
+               convert_to_long_ex(arguments[5]);
+               if ((*arguments[5])->value.lval!=0) persistent=1;
+       }
+
+       if ((*arguments[0])->type == IS_LONG) {
+               if (!module_identifier_exists((*arguments[0])->value.lval)) {
+                       zend_error(E_WARNING, "dbx: module '%ld' not loaded or not supported.\n", (*arguments[0])->value.lval);
+                       return;
+               }
+               module_identifier = (*arguments[0])->value.lval;
+       } else {
+               convert_to_string_ex(arguments[0]);
+               if (!module_exists((*arguments[0])->value.str.val)) {
+                       zend_error(E_WARNING, "dbx: module '%s' not loaded.\n", (*arguments[0])->value.str.val);
+                       return;
+               }
+               module_identifier=get_module_identifier((*arguments[0])->value.str.val);
+               if (!module_identifier) {
+                       zend_error(E_WARNING, "dbx: unsupported module '%s'.\n", (*arguments[0])->value.str.val);
+                       return;
+               }
+       }
+
+       MAKE_STD_ZVAL(dbx_module); 
+       ZVAL_LONG(dbx_module, module_identifier);
+       MAKE_STD_ZVAL(rv_dbx_handle); 
+       ZVAL_LONG(rv_dbx_handle, 0);
+       convert_to_string_ex(arguments[1]);
+       convert_to_string_ex(arguments[2]);
+       convert_to_string_ex(arguments[3]);
+       convert_to_string_ex(arguments[4]);
+       MAKE_STD_ZVAL(db_name); 
+       ZVAL_STRING(db_name, (*arguments[2])->value.str.val, 1);
+       if (persistent) {
+               result = switch_dbx_pconnect(&rv_dbx_handle, arguments[1], arguments[2], arguments[3], arguments[4], INTERNAL_FUNCTION_PARAM_PASSTHRU, &dbx_module);
+       } else {
+               result = switch_dbx_connect(&rv_dbx_handle, arguments[1], arguments[2], arguments[3], arguments[4], INTERNAL_FUNCTION_PARAM_PASSTHRU, &dbx_module);
+       }
+       if (!result) {
+               FREE_ZVAL(dbx_module);
+               zval_dtor(db_name); /* to free stringvalue memory */
+               FREE_ZVAL(db_name);
+               FREE_ZVAL(rv_dbx_handle);
+               RETURN_LONG(0);
+       }
+
+       if (object_init(return_value) != SUCCESS) {
+               zend_error(E_ERROR, "dbx: unable to create resulting object...");
+               FREE_ZVAL(dbx_module);
+               zval_dtor(db_name); /* to free stringvalue memory */
+               FREE_ZVAL(db_name);
+               FREE_ZVAL(rv_dbx_handle);
+               RETURN_LONG(0);
+       }
+
+       zend_hash_update(Z_OBJPROP_P(return_value), "handle", 7, (void *)&(rv_dbx_handle), sizeof(zval *), NULL);
+       zend_hash_update(Z_OBJPROP_P(return_value), "module", 7, (void *)&(dbx_module), sizeof(zval *), NULL);
+       zend_hash_update(Z_OBJPROP_P(return_value), "database", 9, (void *)&(db_name), sizeof(zval *), NULL);
 }
 /* }}} */
 
@@ -300,33 +302,32 @@ ZEND_FUNCTION(dbx_connect)
 */
 ZEND_FUNCTION(dbx_close)
 {
-    int number_of_arguments=1;
-    zval **arguments[1];
+       int number_of_arguments=1;
+       zval **arguments[1];
 
-    int result;
-    zval **dbx_handle;
-    zval **dbx_module;
-    zval **dbx_database;
-    zval * rv_success;
+       int result;
+       zval **dbx_handle;
+       zval **dbx_module;
+       zval **dbx_database;
+       zval *rv_success;
 
-    if (ZEND_NUM_ARGS() !=number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
+       if (ZEND_NUM_ARGS() !=number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
                WRONG_PARAM_COUNT;
-           }
-    if (!split_dbx_handle_object(arguments[0], &dbx_handle, &dbx_module, &dbx_database)) {
-        zend_error(E_WARNING, "dbx_close: not a valid dbx_handle-object...");
-        RETURN_LONG(0);
-        }
-
-    MAKE_STD_ZVAL(rv_success); 
-    ZVAL_LONG(rv_success, 0);
+       }
+       if (!split_dbx_handle_object(arguments[0], &dbx_handle, &dbx_module, &dbx_database)) {
+               zend_error(E_WARNING, "dbx_close: not a valid dbx_handle-object...");
+               RETURN_LONG(0);
+       }
 
-    result = switch_dbx_close(&rv_success, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+       MAKE_STD_ZVAL(rv_success); 
+       ZVAL_LONG(rv_success, 0);
 
-    result = (result && rv_success->value.lval)?1:0;
+       result = switch_dbx_close(&rv_success, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
 
-    FREE_ZVAL(rv_success);
+       result = (result && rv_success->value.lval)?1:0;
+       FREE_ZVAL(rv_success);
 
-    RETURN_LONG(result?1:0);
+       RETURN_LONG(result?1:0);
 }
 /* }}} */
 
@@ -336,168 +337,162 @@ ZEND_FUNCTION(dbx_close)
 */
 ZEND_FUNCTION(dbx_query)
 {
-    int min_number_of_arguments=2;
-    int number_of_arguments=3;
-    zval **arguments[3];
-
-    int result;
-    zval **dbx_handle;
-    zval **dbx_module;
-    zval **dbx_database;
-    zval * rv_result_handle;
-    zval * rv_column_count;
-    long col_index;
-    long row_count;
-    zval * info;
-    long info_flags;
-    zval * data;
-    zval **row_ptr;
-    zval **inforow_ptr;
-
-    if (ZEND_NUM_ARGS()<min_number_of_arguments || ZEND_NUM_ARGS()>number_of_arguments || zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
+       int min_number_of_arguments=2;
+       int number_of_arguments=3;
+       zval **arguments[3];
+
+       int result;
+       zval **dbx_handle;
+       zval **dbx_module;
+       zval **dbx_database;
+       zval *rv_result_handle;
+       zval *rv_column_count;
+       long col_index;
+       long row_count;
+       zval *info;
+       long info_flags;
+       zval *data;
+       zval **row_ptr;
+       zval **inforow_ptr;
+
+       if (ZEND_NUM_ARGS()<min_number_of_arguments || ZEND_NUM_ARGS()>number_of_arguments || zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
                WRONG_PARAM_COUNT;
-           }
-    if (!split_dbx_handle_object(arguments[0], &dbx_handle, &dbx_module, &dbx_database)) {
-        zend_error(E_WARNING, "dbx_query: not a valid dbx_handle-object...");
-        RETURN_LONG(0);
-        }
-    /* default values */
-    info_flags = DBX_RESULT_INFO | DBX_RESULT_INDEX | DBX_RESULT_ASSOC;
-    /* parameter overrides */
-    if (ZEND_NUM_ARGS()>2) {
-        convert_to_long_ex(arguments[2]);
-        info_flags = (*arguments[2])->value.lval;
-        /* fieldnames are needed for association! */
-        if (info_flags & DBX_RESULT_ASSOC) {
-            info_flags |= DBX_RESULT_INFO;
-            }
-        }
-    MAKE_STD_ZVAL(rv_result_handle); 
-    ZVAL_LONG(rv_result_handle, 0);
-    convert_to_string_ex(arguments[1]);
-    result = switch_dbx_query(&rv_result_handle, dbx_handle, dbx_database, arguments[1], INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
-    /* boolean return value means either failure for any query or success for queries that don't return anything  */
-    if (!result || (rv_result_handle && rv_result_handle->type==IS_BOOL)) {
-        result = (result && rv_result_handle->value.lval)?1:0;
-        FREE_ZVAL(rv_result_handle);
-        RETURN_LONG(result?1:0);
-        }
-    /* if you get here, the query succeeded and returned results, so we'll return them
-     * rv_result_handle holds a resource
-     */
-    /* init return_value as object (of rows) */
-    if (object_init(return_value) != SUCCESS) {
-        zend_error(E_ERROR, "dbx_query: unable to create resulting object...");
-        FREE_ZVAL(rv_result_handle);
-        RETURN_LONG(0);
-        }
-    /* add result_handle property to return_value */
-    zend_hash_update(Z_OBJPROP_P(return_value), "handle", 7, (void *)&(rv_result_handle), sizeof(zval *), NULL);
-    /* init info property as array and add to return_value as a property */
-    if (info_flags & DBX_RESULT_INFO) {
-        MAKE_STD_ZVAL(info); 
-        if (array_init(info) != SUCCESS) {
-            zend_error(E_ERROR, "dbx_query: unable to create info-array for results...");
-            FREE_ZVAL(info);
-            RETURN_LONG(0);
-            }
-        zend_hash_update(Z_OBJPROP_P(return_value), "info", 5, (void *)&(info), sizeof(zval *), NULL);
-        }
-    /* init data property as array and add to return_value as a property */
-    MAKE_STD_ZVAL(data); 
-    if (array_init(data) != SUCCESS) {
-        zend_error(E_ERROR, "dbx_query: unable to create data-array for results...");
-        FREE_ZVAL(data);
-        RETURN_LONG(0);
-        }
-    zend_hash_update(Z_OBJPROP_P(return_value), "data", 5, (void *)&(data), sizeof(zval *), NULL);
-    /* get columncount and add to returnvalue as property */
-    MAKE_STD_ZVAL(rv_column_count); 
-    ZVAL_LONG(rv_column_count, 0);
-    result = switch_dbx_getcolumncount(&rv_column_count, &rv_result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
-    if (!result) { 
-        zend_error(E_ERROR, "dbx_query: get column_count failed...");
-        FREE_ZVAL(rv_column_count);
-        RETURN_LONG(0); 
-        }
-    zend_hash_update(Z_OBJPROP_P(return_value), "cols", 5, (void *)&(rv_column_count), sizeof(zval *), NULL);
-    /* fill the info array with columnnames and types (indexed and assoc) */
-    if (info_flags & DBX_RESULT_INFO) {
-        zval * info_row_name;
-        zval * info_row_type;
-        MAKE_STD_ZVAL(info_row_name);
-        MAKE_STD_ZVAL(info_row_type);
-        if (array_init(info_row_name) != SUCCESS) {
-            zend_error(E_ERROR, "dbx_query: unable to create info_row_name-array for results...");
-            FREE_ZVAL(info_row_name);
-            FREE_ZVAL(info_row_type);
-            RETURN_LONG(0);
-            }
-        if (array_init(info_row_type) != SUCCESS) {
-            zend_error(E_ERROR, "dbx_query: unable to create info_row_type-array for results...");
-            FREE_ZVAL(info_row_name);
-            FREE_ZVAL(info_row_type);
-            RETURN_LONG(0);
-            }
-        for (col_index=0; col_index<rv_column_count->value.lval; ++col_index) {
-            zval * rv_column_name;
-            zval * rv_column_type;
-            /* get name */
-            MAKE_STD_ZVAL(rv_column_name);
-            ZVAL_LONG(rv_column_name, 0);
-            result = switch_dbx_getcolumnname(&rv_column_name, &rv_result_handle, col_index, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
-            if (result) { 
-                zend_hash_index_update(info_row_name->value.ht, col_index, (void *)&(rv_column_name), sizeof(zval *), NULL);
-                }
-            else {
-                FREE_ZVAL(rv_column_name);
-                }
-            /* get type */
-            MAKE_STD_ZVAL(rv_column_type);
-            ZVAL_LONG(rv_column_type, 0);
-            result = switch_dbx_getcolumntype(&rv_column_type, &rv_result_handle, col_index, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
-            if (result) { 
-                zend_hash_index_update(info_row_type->value.ht, col_index, (void *)&(rv_column_type), sizeof(zval *), NULL);
-                }
-            else {
-                FREE_ZVAL(rv_column_type);
-                }
-            }
-        zend_hash_update(info->value.ht, "name", 5, (void *) &info_row_name, sizeof(zval *), (void **) &inforow_ptr);
-        zend_hash_update(info->value.ht, "type", 5, (void *) &info_row_type, sizeof(zval *), NULL);
-        }
-    /* fill each row array with fieldvalues (indexed (and assoc)) */
-    row_count=0;
-    result=1;
-    while (result) {
-        zval * rv_row;
-        MAKE_STD_ZVAL(rv_row);
-        ZVAL_LONG(rv_row, 0);
-        result = switch_dbx_getrow(&rv_row, &rv_result_handle, row_count, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
-        if (result) {
-            zend_hash_index_update(data->value.ht, row_count, (void *)&(rv_row), sizeof(zval *), (void **) &row_ptr);
-            /* associate results with fieldnames */
-            if (info_flags & DBX_RESULT_ASSOC) {
-                zval **columnname_ptr, **actual_ptr;
-                for (col_index=0; col_index<rv_column_count->value.lval; ++col_index) {
-                    zend_hash_index_find((*inforow_ptr)->value.ht, col_index, (void **) &columnname_ptr);
-                    zend_hash_index_find((*row_ptr)->value.ht, col_index, (void **) &actual_ptr);
-                    (*actual_ptr)->refcount+=1;
-
-                    (*actual_ptr)->is_ref=1;
-
-                    zend_hash_update((*row_ptr)->value.ht, (*columnname_ptr)->value.str.val, (*columnname_ptr)->value.str.len + 1, actual_ptr, sizeof(zval *), NULL);
-
-                    }
-                }
-            ++row_count;
-            }
-        else {
-            FREE_ZVAL(rv_row);
-            }
-        }
-    /* add row_count property */
-    add_property_long(return_value, "rows", row_count);
+       }
+       if (!split_dbx_handle_object(arguments[0], &dbx_handle, &dbx_module, &dbx_database)) {
+               zend_error(E_WARNING, "dbx_query: not a valid dbx_handle-object...");
+               RETURN_LONG(0);
+       }
+       /* default values */
+       info_flags = DBX_RESULT_INFO | DBX_RESULT_INDEX | DBX_RESULT_ASSOC;
+       /* parameter overrides */
+       if (ZEND_NUM_ARGS()>2) {
+               convert_to_long_ex(arguments[2]);
+               info_flags = (*arguments[2])->value.lval;
+               /* fieldnames are needed for association! */
+               if (info_flags & DBX_RESULT_ASSOC) {
+                       info_flags |= DBX_RESULT_INFO;
+               }
+       }
+       MAKE_STD_ZVAL(rv_result_handle); 
+       ZVAL_LONG(rv_result_handle, 0);
+       convert_to_string_ex(arguments[1]);
+       result = switch_dbx_query(&rv_result_handle, dbx_handle, dbx_database, arguments[1], INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+       /* boolean return value means either failure for any query or success for queries that don't return anything  */
+       if (!result || (rv_result_handle && rv_result_handle->type==IS_BOOL)) {
+               result = (result && rv_result_handle->value.lval)?1:0;
+               FREE_ZVAL(rv_result_handle);
+               RETURN_LONG(result?1:0);
+       }
+       /* if you get here, the query succeeded and returned results, so we'll return them
+        * rv_result_handle holds a resource
+        */
+       /* init return_value as object (of rows) */
+       if (object_init(return_value) != SUCCESS) {
+               zend_error(E_ERROR, "dbx_query: unable to create resulting object...");
+               FREE_ZVAL(rv_result_handle);
+               RETURN_LONG(0);
+       }
+       /* add result_handle property to return_value */
+       zend_hash_update(Z_OBJPROP_P(return_value), "handle", 7, (void *)&(rv_result_handle), sizeof(zval *), NULL);
+       /* init info property as array and add to return_value as a property */
+       if (info_flags & DBX_RESULT_INFO) {
+               MAKE_STD_ZVAL(info); 
+               if (array_init(info) != SUCCESS) {
+                       zend_error(E_ERROR, "dbx_query: unable to create info-array for results...");
+                       FREE_ZVAL(info);
+                       RETURN_LONG(0);
+               }
+               zend_hash_update(Z_OBJPROP_P(return_value), "info", 5, (void *)&(info), sizeof(zval *), NULL);
+       }
+       /* init data property as array and add to return_value as a property */
+       MAKE_STD_ZVAL(data); 
+       if (array_init(data) != SUCCESS) {
+               zend_error(E_ERROR, "dbx_query: unable to create data-array for results...");
+               FREE_ZVAL(data);
+               RETURN_LONG(0);
+       }
+       zend_hash_update(Z_OBJPROP_P(return_value), "data", 5, (void *)&(data), sizeof(zval *), NULL);
+       /* get columncount and add to returnvalue as property */
+       MAKE_STD_ZVAL(rv_column_count); 
+       ZVAL_LONG(rv_column_count, 0);
+       result = switch_dbx_getcolumncount(&rv_column_count, &rv_result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+       if (!result) { 
+               zend_error(E_ERROR, "dbx_query: get column_count failed...");
+               FREE_ZVAL(rv_column_count);
+               RETURN_LONG(0); 
+       }
+       zend_hash_update(Z_OBJPROP_P(return_value), "cols", 5, (void *)&(rv_column_count), sizeof(zval *), NULL);
+       /* fill the info array with columnnames and types (indexed and assoc) */
+       if (info_flags & DBX_RESULT_INFO) {
+               zval *info_row_name;
+               zval *info_row_type;
+               MAKE_STD_ZVAL(info_row_name);
+               MAKE_STD_ZVAL(info_row_type);
+               if (array_init(info_row_name) != SUCCESS) {
+                       zend_error(E_ERROR, "dbx_query: unable to create info_row_name-array for results...");
+                       FREE_ZVAL(info_row_name);
+                       FREE_ZVAL(info_row_type);
+                       RETURN_LONG(0);
+               }
+               if (array_init(info_row_type) != SUCCESS) {
+                       zend_error(E_ERROR, "dbx_query: unable to create info_row_type-array for results...");
+                       FREE_ZVAL(info_row_name);
+                       FREE_ZVAL(info_row_type);
+                       RETURN_LONG(0);
+               }
+               for (col_index=0; col_index<rv_column_count->value.lval; ++col_index) {
+                       zval *rv_column_name;
+                       zval *rv_column_type;
+                       /* get name */
+                       MAKE_STD_ZVAL(rv_column_name);
+                       ZVAL_LONG(rv_column_name, 0);
+                       result = switch_dbx_getcolumnname(&rv_column_name, &rv_result_handle, col_index, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+                       if (result) { 
+                               zend_hash_index_update(info_row_name->value.ht, col_index, (void *)&(rv_column_name), sizeof(zval *), NULL);
+                       } else {
+                               FREE_ZVAL(rv_column_name);
+                       }
+                       /* get type */
+                       MAKE_STD_ZVAL(rv_column_type);
+                       ZVAL_LONG(rv_column_type, 0);
+                       result = switch_dbx_getcolumntype(&rv_column_type, &rv_result_handle, col_index, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+                       if (result) { 
+                               zend_hash_index_update(info_row_type->value.ht, col_index, (void *)&(rv_column_type), sizeof(zval *), NULL);
+                       } else {
+                               FREE_ZVAL(rv_column_type);
+                       }
+               }
+               zend_hash_update(info->value.ht, "name", 5, (void *) &info_row_name, sizeof(zval *), (void **) &inforow_ptr);
+               zend_hash_update(info->value.ht, "type", 5, (void *) &info_row_type, sizeof(zval *), NULL);
+       }
+       /* fill each row array with fieldvalues (indexed (and assoc)) */
+       row_count=0;
+       result=1;
+       while (result) {
+               zval *rv_row;
+               MAKE_STD_ZVAL(rv_row);
+               ZVAL_LONG(rv_row, 0);
+               result = switch_dbx_getrow(&rv_row, &rv_result_handle, row_count, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+               if (result) {
+                       zend_hash_index_update(data->value.ht, row_count, (void *)&(rv_row), sizeof(zval *), (void **) &row_ptr);
+                       /* associate results with fieldnames */
+                       if (info_flags & DBX_RESULT_ASSOC) {
+                               zval **columnname_ptr, **actual_ptr;
+                               for (col_index=0; col_index<rv_column_count->value.lval; ++col_index) {
+                                       zend_hash_index_find((*inforow_ptr)->value.ht, col_index, (void **) &columnname_ptr);
+                                       zend_hash_index_find((*row_ptr)->value.ht, col_index, (void **) &actual_ptr);
+                                       (*actual_ptr)->refcount+=1;
+                                       (*actual_ptr)->is_ref=1;
+                                       zend_hash_update((*row_ptr)->value.ht, (*columnname_ptr)->value.str.val, (*columnname_ptr)->value.str.len + 1, actual_ptr, sizeof(zval *), NULL);
+                               }
+                       }
+                       ++row_count;
+               } else {
+                       FREE_ZVAL(rv_row);
+               }
+       }
+       /* add row_count property */
+       add_property_long(return_value, "rows", row_count);
 }
 /* }}} */
 
@@ -506,31 +501,31 @@ ZEND_FUNCTION(dbx_query)
 */
 ZEND_FUNCTION(dbx_error)
 {
-    int number_of_arguments=1;
-    zval **arguments[1];
+       int number_of_arguments=1;
+       zval **arguments[1];
 
-    int result;
-    zval **dbx_handle;
-    zval **dbx_module;
-    zval **dbx_database;
-    zval * rv_errormsg;
+       int result;
+       zval **dbx_handle;
+       zval **dbx_module;
+       zval **dbx_database;
+       zval *rv_errormsg;
 
-    if (ZEND_NUM_ARGS() !=number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
+       if (ZEND_NUM_ARGS() !=number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
                WRONG_PARAM_COUNT;
-           }
-    if (!split_dbx_handle_object(arguments[0], &dbx_handle, &dbx_module, &dbx_database)) {
-        zend_error(E_WARNING, "dbx_error: not a valid dbx_handle-object...");
-        RETURN_LONG(0);
-        }
-
-    MAKE_STD_ZVAL(rv_errormsg); 
-    ZVAL_LONG(rv_errormsg, 0);
-    result = switch_dbx_error(&rv_errormsg, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
-    if (!result) {
-        FREE_ZVAL(rv_errormsg);
-        RETURN_STRING("", 1); 
-        }
-    MOVE_RETURNED_TO_RV(&return_value, rv_errormsg);
+       }
+       if (!split_dbx_handle_object(arguments[0], &dbx_handle, &dbx_module, &dbx_database)) {
+               zend_error(E_WARNING, "dbx_error: not a valid dbx_handle-object...");
+               RETURN_LONG(0);
+       }
+
+       MAKE_STD_ZVAL(rv_errormsg); 
+       ZVAL_LONG(rv_errormsg, 0);
+       result = switch_dbx_error(&rv_errormsg, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+       if (!result) {
+               FREE_ZVAL(rv_errormsg);
+               RETURN_STRING("", 1); 
+       }
+       MOVE_RETURNED_TO_RV(&return_value, rv_errormsg);
 }
 /* }}} */
 
@@ -543,90 +538,90 @@ ZEND_FUNCTION(dbx_error)
 */
 ZEND_FUNCTION(dbx_compare)
 {
-    int min_number_of_arguments=3;
-    int max_number_of_arguments=4;
-    int number_of_arguments=-1;
-    long comparison_direction=DBX_CMP_ASC;
-    long comparison_type=DBX_CMP_NATIVE;
-    double dtemp;
-    long ltemp;
-    zval **arguments[4];
-    zval **zv_a;
-    zval **zv_b;
-    int result=0;
-    number_of_arguments=ZEND_NUM_ARGS();
-    if (number_of_arguments<min_number_of_arguments || number_of_arguments>max_number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
+       int min_number_of_arguments=3;
+       int max_number_of_arguments=4;
+       int number_of_arguments=-1;
+       long comparison_direction=DBX_CMP_ASC;
+       long comparison_type=DBX_CMP_NATIVE;
+       double dtemp;
+       long ltemp;
+       zval **arguments[4];
+       zval **zv_a;
+       zval **zv_b;
+       int result=0;
+       number_of_arguments=ZEND_NUM_ARGS();
+       if (number_of_arguments<min_number_of_arguments || number_of_arguments>max_number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
                WRONG_PARAM_COUNT;
-           }
-
-    if ((*arguments[0])->type != IS_ARRAY
-    || (*arguments[1])->type != IS_ARRAY) {
-        zend_error(E_WARNING, "Wrong argument type for compare");
-        RETURN_LONG(0);
-        }
-    convert_to_string_ex(arguments[2]); /* field name */
-    comparison_type = DBX_CMP_NATIVE;
-    comparison_direction = DBX_CMP_ASC;
-    if (number_of_arguments>3) {
-        convert_to_long_ex(arguments[3]); /* comparison type and direction*/
-        /* direction */
-        if ((*arguments[3])->value.lval & DBX_CMP_DESC) {
-            comparison_direction=DBX_CMP_DESC;
-            }
-        if ((*arguments[3])->value.lval & DBX_CMP_ASC) {
-            comparison_direction=DBX_CMP_ASC;
-            }
-        /* type */
-        if ((*arguments[3])->value.lval & DBX_CMP_NUMBER) {
-            comparison_type=DBX_CMP_NUMBER;
-            }
-        if ((*arguments[3])->value.lval & DBX_CMP_TEXT) {
-            comparison_type=DBX_CMP_TEXT;
-            }
-        if ((*arguments[3])->value.lval & DBX_CMP_NATIVE) {
-            comparison_type=DBX_CMP_NATIVE;
-            }
-        }
-
-    if (zend_hash_find((*arguments[0])->value.ht, (*arguments[2])->value.str.val, (*arguments[2])->value.str.len+1, (void **) &zv_a)==FAILURE
-    || zend_hash_find((*arguments[1])->value.ht, (*arguments[2])->value.str.val, (*arguments[2])->value.str.len+1, (void **) &zv_b)==FAILURE)  {
-        zend_error(E_WARNING, "Field '%s' not available in result-object", (*arguments[2])->value.str.val);
-        RETURN_LONG(0);
-        }
-
-    switch (comparison_type) {
-        case DBX_CMP_TEXT:
-            convert_to_string_ex(zv_a);
-            convert_to_string_ex(zv_b);
-            break;
-        case DBX_CMP_NUMBER:
-            convert_to_double_ex(zv_a);
-            convert_to_double_ex(zv_b);
-            break;
-        }
-    switch ((*zv_a)->type) {
-        case IS_NULL:
-            result=0;
-            break;
-        case IS_BOOL:
-        case IS_LONG:
-        case IS_CONSTANT:
-            ltemp = (*zv_a)->value.lval - (*zv_b)->value.lval;
-            result = (ltemp==0?0: (ltemp>0?1:-1));
-            break;
-        case IS_DOUBLE:
-            dtemp = ((*zv_a)->value.dval - (*zv_b)->value.dval);
-            result = (dtemp==0?0: (dtemp>0?1:-1));
-            break;
-        case IS_STRING:
-            ltemp = strcmp((*zv_a)->value.str.val, (*zv_b)->value.str.val);
-            result = (ltemp==0?0: (ltemp>0?1:-1));
-            break;
-        default: result=0;
-        }
-
-    if (comparison_direction==DBX_CMP_DESC) RETURN_LONG(-result);
-    RETURN_LONG(result);
+       }
+
+       if ((*arguments[0])->type != IS_ARRAY
+       || (*arguments[1])->type != IS_ARRAY) {
+               zend_error(E_WARNING, "Wrong argument type for compare");
+               RETURN_LONG(0);
+       }
+       convert_to_string_ex(arguments[2]); /* field name */
+       comparison_type = DBX_CMP_NATIVE;
+       comparison_direction = DBX_CMP_ASC;
+       if (number_of_arguments>3) {
+               convert_to_long_ex(arguments[3]); /* comparison type and direction*/
+               /* direction */
+               if ((*arguments[3])->value.lval & DBX_CMP_DESC) {
+                       comparison_direction=DBX_CMP_DESC;
+               }
+               if ((*arguments[3])->value.lval & DBX_CMP_ASC) {
+                       comparison_direction=DBX_CMP_ASC;
+               }
+               /* type */
+               if ((*arguments[3])->value.lval & DBX_CMP_NUMBER) {
+                       comparison_type=DBX_CMP_NUMBER;
+               }
+               if ((*arguments[3])->value.lval & DBX_CMP_TEXT) {
+                       comparison_type=DBX_CMP_TEXT;
+               }
+               if ((*arguments[3])->value.lval & DBX_CMP_NATIVE) {
+                       comparison_type=DBX_CMP_NATIVE;
+               }
+       }
+
+       if (zend_hash_find((*arguments[0])->value.ht, (*arguments[2])->value.str.val, (*arguments[2])->value.str.len+1, (void **) &zv_a)==FAILURE
+       || zend_hash_find((*arguments[1])->value.ht, (*arguments[2])->value.str.val, (*arguments[2])->value.str.len+1, (void **) &zv_b)==FAILURE)  {
+               zend_error(E_WARNING, "Field '%s' not available in result-object", (*arguments[2])->value.str.val);
+               RETURN_LONG(0);
+       }
+
+       switch (comparison_type) {
+               case DBX_CMP_TEXT:
+                       convert_to_string_ex(zv_a);
+                       convert_to_string_ex(zv_b);
+                       break;
+               case DBX_CMP_NUMBER:
+                       convert_to_double_ex(zv_a);
+                       convert_to_double_ex(zv_b);
+                       break;
+       }
+       switch ((*zv_a)->type) {
+               case IS_NULL:
+                       result=0;
+                       break;
+               case IS_BOOL:
+               case IS_LONG:
+               case IS_CONSTANT:
+                       ltemp = (*zv_a)->value.lval - (*zv_b)->value.lval;
+                       result = (ltemp==0?0: (ltemp>0?1:-1));
+                       break;
+               case IS_DOUBLE:
+                       dtemp = ((*zv_a)->value.dval - (*zv_b)->value.dval);
+                       result = (dtemp==0?0: (dtemp>0?1:-1));
+                       break;
+               case IS_STRING:
+                       ltemp = strcmp((*zv_a)->value.str.val, (*zv_b)->value.str.val);
+                       result = (ltemp==0?0: (ltemp>0?1:-1));
+                       break;
+               default: result=0;
+       }
+
+       if (comparison_direction==DBX_CMP_DESC) RETURN_LONG(-result);
+       RETURN_LONG(result);
 }
 
 
@@ -635,32 +630,32 @@ ZEND_FUNCTION(dbx_compare)
 */
 ZEND_FUNCTION(dbx_sort)
 {
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval **zval_data;
-    zval * returned_zval;
-    int result=0;
-    if (ZEND_NUM_ARGS() !=number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval **zval_data;
+       zval *returned_zval;
+       int result=0;
+       if (ZEND_NUM_ARGS() !=number_of_arguments || zend_get_parameters_array_ex(number_of_arguments, arguments) == FAILURE) {
                WRONG_PARAM_COUNT;
-           }
-
-    if ((*arguments[0])->type != IS_OBJECT
-    || (*arguments[1])->type != IS_STRING) {
-        zend_error(E_WARNING, "Wrong argument type for sort");
-        RETURN_LONG(0);
-        }
-
-    if (zend_hash_find(Z_OBJPROP_PP(arguments[0]), "data", 5, (void **) &zval_data)==FAILURE
-    || (*zval_data)->type != IS_ARRAY) {
-        zend_error(E_WARNING, "Wrong argument type for sort");
-        RETURN_LONG(0);
-        }
-
-    arguments[0] = zval_data;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "usort", &returned_zval, number_of_arguments, arguments);
+       }
+
+       if ((*arguments[0])->type != IS_OBJECT
+       || (*arguments[1])->type != IS_STRING) {
+               zend_error(E_WARNING, "Wrong argument type for sort");
+               RETURN_LONG(0);
+       }
+
+       if (zend_hash_find(Z_OBJPROP_PP(arguments[0]), "data", 5, (void **) &zval_data)==FAILURE
+       || (*zval_data)->type != IS_ARRAY) {
+               zend_error(E_WARNING, "Wrong argument type for sort");
+               RETURN_LONG(0);
+       }
+
+       arguments[0] = zval_data;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "usort", &returned_zval, number_of_arguments, arguments);
        zval_ptr_dtor(&returned_zval);
-    
-    RETURN_LONG(1);
+       
+       RETURN_LONG(1);
 }
 
 /***********************************/
@@ -668,131 +663,142 @@ ZEND_FUNCTION(dbx_sort)
 /*
  * switch_dbx functions
  */
-int switch_dbx_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: zend_error(E_WARNING, "dbx_connect: OCI8 extension is still highly experimental!"); return dbx_oci8_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_connect: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: zend_error(E_WARNING, "dbx_pconnect: OCI8 extension is still highly experimental!"); return dbx_oci8_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_pconnect: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns 1 as long on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_close: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns 1 as long or result identifier as resource on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_query: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns column-count as long on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_getcolumncount: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns column-name as string on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_getcolumnname: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns column-type as string on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-       }
-    zend_error(E_WARNING, "dbx_getcolumntype: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_getrow: not supported in this module");
-    return 0;
-    }
-
-int switch_dbx_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module) {
-    /* returns string */
-    switch ((*dbx_module)->value.lval) {
-        case DBX_MYSQL: return dbx_mysql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_ODBC: return dbx_odbc_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_PGSQL: return dbx_pgsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_MSSQL: return dbx_mssql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_FBSQL: return dbx_fbsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        case DBX_OCI8: return dbx_oci8_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);        
-        }
-    zend_error(E_WARNING, "dbx_error: not supported in this module");
-    return 0;
-    }
+int switch_dbx_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  zend_error(E_WARNING, "dbx_connect: OCI8 extension is still highly experimental!"); 
+                       return dbx_oci8_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_connect: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  zend_error(E_WARNING, "dbx_pconnect: OCI8 extension is still highly experimental!"); 
+                       return dbx_oci8_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_pconnect: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_close: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns 1 as long or result identifier as resource on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_query: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_getcolumncount: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_getcolumnname: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_getcolumntype: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_getrow: not supported in this module");
+       return 0;
+}
+
+int switch_dbx_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, zval **dbx_module)
+{
+       /* returns string */
+       switch ((*dbx_module)->value.lval) {
+               case DBX_MYSQL: return dbx_mysql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_ODBC:  return dbx_odbc_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_PGSQL: return dbx_pgsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_MSSQL: return dbx_mssql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_FBSQL: return dbx_fbsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+               case DBX_OCI8:  return dbx_oci8_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
+       }
+       zend_error(E_WARNING, "dbx_error: not supported in this module");
+       return 0;
+}
 
 /*
  * Local variables:
index e0f4ec84e61c416cffa9db89b7f1f88491e38a40..8e9b7fdd08f0e633d5df778903187c83fae34adb 100644 (file)
 
 #define DBX_PERSISTENT        (1<<0)
 
-#define DBX_RESULT_INFO      (1<<0)
-#define DBX_RESULT_INDEX    (1<<1)
-#define DBX_RESULT_ASSOC   (1<<2)
+#define DBX_RESULT_INFO       (1<<0)
+#define DBX_RESULT_INDEX      (1<<1)
+#define DBX_RESULT_ASSOC      (1<<2)
 
-#define DBX_CMP_NATIVE      (1<<0)
+#define DBX_CMP_NATIVE        (1<<0)
 #define DBX_CMP_TEXT          (1<<1)
-#define DBX_CMP_NUMBER      (1<<2)
+#define DBX_CMP_NUMBER        (1<<2)
 #define DBX_CMP_ASC           (1<<3)
 #define DBX_CMP_DESC          (1<<4)
 
 #define MOVE_RETURNED_TO_RV(rv, returned_zval) { **rv = *returned_zval; zval_copy_ctor(*rv); zval_ptr_dtor(&returned_zval); }
 
-void dbx_call_any_function(INTERNAL_FUNCTION_PARAMETERS, char * function_name, zval **returnvalue, int number_of_arguments, zval *** params);
+void dbx_call_any_function(INTERNAL_FUNCTION_PARAMETERS, char *function_name, zval **returnvalue, int number_of_arguments, zval ***params);
 
-#endif /* ZEND_DBX_H */
+#endif /* ZEND_DBX_H */
 
 
 /*
index 840ed01ccf5aabe9b9a99a91dda78a62b73709c4..edc7b5586e7a23724eeef63de1bb49620f5a86dd 100644 (file)
 #include "dbx.h"
 #include "dbx_fbsql.h"
 
-#define FBSQL_ASSOC            1<<0
-#define FBSQL_NUM              1<<1
-
-int dbx_fbsql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    arguments[0]=host;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_connect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-
-    number_of_arguments=2;
-    arguments[0]=db;
-    arguments[1]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_select_db", &select_db_zval, number_of_arguments, arguments);
-    if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        /* also close connection */
-        number_of_arguments=1;
-        arguments[0]=&returned_zval;
-        zend_list_addref(returned_zval->value.lval);
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_close", &select_db_zval, number_of_arguments, arguments);
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&select_db_zval);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
-    }
-
-int dbx_fbsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    arguments[0]=host;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_pconnect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-
-    number_of_arguments=2;
-    arguments[0]=db;
-    arguments[1]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_select_db", &select_db_zval, number_of_arguments, arguments);
-    if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        /* also close connection */
-        number_of_arguments=1;
-        arguments[0]=&returned_zval;
-        zend_list_addref(returned_zval->value.lval);
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_close", &select_db_zval, number_of_arguments, arguments);
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&select_db_zval);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
-    }
-
-int dbx_fbsql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_close", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_BOOL) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_fbsql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-
-    arguments[0]=db_name;
-    arguments[1]=sql_statement;
-    arguments[2]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_db_query", &returned_zval, number_of_arguments, arguments);
-    /* fbsql_query returns a bool for success or failure, or a result_identifier for select statements */
-    if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_fbsql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-count as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_num_fields", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_LONG) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_fbsql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-name as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_field_name", &returned_zval, number_of_arguments, arguments);
-    /* fbsql_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_fbsql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-type as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_field_type", &returned_zval, number_of_arguments, arguments);
-    /* fbsql_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_fbsql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_resulttype=NULL;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_resulttype);
-    ZVAL_LONG(zval_resulttype, FBSQL_NUM);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_resulttype;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_fetch_array", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_ARRAY) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_resulttype);
-        return 0;
-        }
-    FREE_ZVAL(zval_resulttype);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_fbsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns string */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    if (!dbx_handle) number_of_arguments=0;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_error", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+#define FBSQL_ASSOC    1<<0
+#define FBSQL_NUM      1<<1
+
+int dbx_fbsql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       arguments[0]=host;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_connect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+
+       number_of_arguments=2;
+       arguments[0]=db;
+       arguments[1]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_select_db", &select_db_zval, number_of_arguments, arguments);
+       if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               /* also close connection */
+               number_of_arguments=1;
+               arguments[0]=&returned_zval;
+               zend_list_addref(returned_zval->value.lval);
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_close", &select_db_zval, number_of_arguments, arguments);
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&select_db_zval);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       arguments[0]=host;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_pconnect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+
+       number_of_arguments=2;
+       arguments[0]=db;
+       arguments[1]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_select_db", &select_db_zval, number_of_arguments, arguments);
+       if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               /* also close connection */
+               number_of_arguments=1;
+               arguments[0]=&returned_zval;
+               zend_list_addref(returned_zval->value.lval);
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_close", &select_db_zval, number_of_arguments, arguments);
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&select_db_zval);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_close", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_BOOL) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+
+       arguments[0]=db_name;
+       arguments[1]=sql_statement;
+       arguments[2]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_db_query", &returned_zval, number_of_arguments, arguments);
+       /* fbsql_query returns a bool for success or failure, or a result_identifier for select statements */
+       if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_num_fields", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_LONG) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_field_name", &returned_zval, number_of_arguments, arguments);
+       /* fbsql_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_field_type", &returned_zval, number_of_arguments, arguments);
+       /* fbsql_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_resulttype=NULL;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_resulttype);
+       ZVAL_LONG(zval_resulttype, FBSQL_NUM);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_resulttype;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_fetch_array", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_ARRAY) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_resulttype);
+               return 0;
+       }
+       FREE_ZVAL(zval_resulttype);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_fbsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns string */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       if (!dbx_handle) number_of_arguments=0;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "fbsql_error", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
 /*
  * Local variables:
index 5c2010be4d34baf30d1f7f8e236252490f05e41b..78a0d55bbb698fb7af2fc375e39798d512216db5 100644 (file)
 #include "php.h"
 
 int dbx_fbsql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int dbx_fbsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
 int dbx_fbsql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int dbx_fbsql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
 int dbx_fbsql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int dbx_fbsql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int dbx_fbsql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int dbx_fbsql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int dbx_fbsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns string */
+       /* returns string */
 
-#endif /* ZEND_DBX_FBSQL_H */
+#endif /* ZEND_DBX_FBSQL_H */
 
 /*
  * Local variables:
index 45ce0daf94af215c05f6447bc985e05190e29e15..af66d7bbf2ce385596f2e1964e97787467c8964d 100644 (file)
 #include "dbx.h"
 #include "dbx_mssql.h"
 
-#define MSSQL_ASSOC            1<<0
-#define MSSQL_NUM              1<<1
-
-int dbx_mssql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    arguments[0]=host;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_connect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-
-    number_of_arguments=2;
-    arguments[0]=db;
-    arguments[1]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_select_db", &select_db_zval, number_of_arguments, arguments);
-    if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        /* also close connection */
-        number_of_arguments=1;
-        arguments[0]=&returned_zval;
-        zend_list_addref(returned_zval->value.lval);
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &select_db_zval, number_of_arguments, arguments);
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&select_db_zval);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
-    }
-
-int dbx_mssql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    arguments[0]=host;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_pconnect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-
-    number_of_arguments=2;
-    arguments[0]=db;
-    arguments[1]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_select_db", &select_db_zval, number_of_arguments, arguments);
-    if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        /* also close connection */
-        number_of_arguments=1;
-        arguments[0]=&returned_zval;
-        zend_list_addref(returned_zval->value.lval);
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &select_db_zval, number_of_arguments, arguments);
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&select_db_zval);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
-    }
-
-int dbx_mssql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_BOOL) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mssql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    number_of_arguments=2;
-    arguments[0]=db_name;
-    arguments[1]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_select_db", &select_db_zval, number_of_arguments, arguments);
-    zval_ptr_dtor(&select_db_zval);
-
-    number_of_arguments=2;
-    arguments[0]=sql_statement;
-    arguments[1]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_query", &returned_zval, number_of_arguments, arguments);
-    /* mssql_query returns a bool for success or failure, or a result_identifier for select statements */
-    if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mssql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-count as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_num_fields", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_LONG) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mssql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-name as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_field_name", &returned_zval, number_of_arguments, arguments);
-    /* mssql_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mssql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-type as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_field_type", &returned_zval, number_of_arguments, arguments);
-    /* mssql_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mssql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_fetch_row", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_ARRAY) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mssql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns string */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    if (!dbx_handle) number_of_arguments=0;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_get_last_message", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+#define MSSQL_ASSOC    1<<0
+#define MSSQL_NUM      1<<1
+
+int dbx_mssql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       arguments[0]=host;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_connect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+
+       number_of_arguments=2;
+       arguments[0]=db;
+       arguments[1]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_select_db", &select_db_zval, number_of_arguments, arguments);
+       if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               /* also close connection */
+               number_of_arguments=1;
+               arguments[0]=&returned_zval;
+               zend_list_addref(returned_zval->value.lval);
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &select_db_zval, number_of_arguments, arguments);
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&select_db_zval);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       arguments[0]=host;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_pconnect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+
+       number_of_arguments=2;
+       arguments[0]=db;
+       arguments[1]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_select_db", &select_db_zval, number_of_arguments, arguments);
+       if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               /* also close connection */
+               number_of_arguments=1;
+               arguments[0]=&returned_zval;
+               zend_list_addref(returned_zval->value.lval);
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &select_db_zval, number_of_arguments, arguments);
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&select_db_zval);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_close", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_BOOL) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       number_of_arguments=2;
+       arguments[0]=db_name;
+       arguments[1]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_select_db", &select_db_zval, number_of_arguments, arguments);
+       zval_ptr_dtor(&select_db_zval);
+
+       number_of_arguments=2;
+       arguments[0]=sql_statement;
+       arguments[1]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_query", &returned_zval, number_of_arguments, arguments);
+       /* mssql_query returns a bool for success or failure, or a result_identifier for select statements */
+       if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_num_fields", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_LONG) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_field_name", &returned_zval, number_of_arguments, arguments);
+       /* mssql_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_field_type", &returned_zval, number_of_arguments, arguments);
+       /* mssql_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_fetch_row", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_ARRAY) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mssql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns string */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       if (!dbx_handle) number_of_arguments=0;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mssql_get_last_message", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
 /*
  * Local variables:
index 8f1226052a2918ad02cb77526bc614b9c3819e7a..c164c2d7721d511764f64d59909835820d73c268 100644 (file)
 #include "php.h"
 
 int dbx_mssql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int dbx_mssql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
 int dbx_mssql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int dbx_mssql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
 int dbx_mssql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int dbx_mssql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int dbx_mssql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int dbx_mssql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int dbx_mssql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns string */
+       /* returns string */
 
-#endif /* ZEND_DBX_MSSQL_H */
+#endif /* ZEND_DBX_MSSQL_H */
 
 /*
  * Local variables:
index ad7316cc796af2f8a887b7ad77d032c21f996b93..0e5f86d8dc38c3d34d42ec8a6c438a14432bb7fc 100644 (file)
 #include "dbx.h"
 #include "dbx_mysql.h"
 
-#define MYSQL_ASSOC            1<<0
-#define MYSQL_NUM              1<<1
-
-int dbx_mysql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    arguments[0]=host;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_connect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-
-    number_of_arguments=2;
-    arguments[0]=db;
-    arguments[1]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_select_db", &select_db_zval, number_of_arguments, arguments);
-    if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        /* also close connection */
-        number_of_arguments=1;
-        arguments[0]=&returned_zval;
-        zend_list_addref(returned_zval->value.lval);
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &select_db_zval, number_of_arguments, arguments);
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&select_db_zval);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
-    }
-
-int dbx_mysql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-    zval * select_db_zval=NULL;
-
-    arguments[0]=host;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_pconnect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-
-    number_of_arguments=2;
-    arguments[0]=db;
-    arguments[1]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_select_db", &select_db_zval, number_of_arguments, arguments);
-    if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        /* also close connection */
-        number_of_arguments=1;
-        arguments[0]=&returned_zval;
-        zend_list_addref(returned_zval->value.lval);
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &select_db_zval, number_of_arguments, arguments);
-        if (select_db_zval) zval_ptr_dtor(&select_db_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&select_db_zval);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
-    }
-
-int dbx_mysql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_BOOL) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mysql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-
-    arguments[0]=db_name;
-    arguments[1]=sql_statement;
-    arguments[2]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_db_query", &returned_zval, number_of_arguments, arguments);
-    /* mysql_query returns a bool for success or failure, or a result_identifier for select statements */
-    if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mysql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-count as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_num_fields", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_LONG) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mysql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-name as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_field_name", &returned_zval, number_of_arguments, arguments);
-    /* mysql_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mysql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-type as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_field_type", &returned_zval, number_of_arguments, arguments);
-    /* mysql_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mysql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_resulttype=NULL;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_resulttype);
-    ZVAL_LONG(zval_resulttype, MYSQL_NUM);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_resulttype;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_fetch_array", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_ARRAY) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_resulttype);
-        return 0;
-        }
-    FREE_ZVAL(zval_resulttype);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_mysql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns string */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    if (!dbx_handle) number_of_arguments=0;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_error", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+#define MYSQL_ASSOC    1<<0
+#define MYSQL_NUM      1<<1
+
+int dbx_mysql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       arguments[0]=host;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_connect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+
+       number_of_arguments=2;
+       arguments[0]=db;
+       arguments[1]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_select_db", &select_db_zval, number_of_arguments, arguments);
+       if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               /* also close connection */
+               number_of_arguments=1;
+               arguments[0]=&returned_zval;
+               zend_list_addref(returned_zval->value.lval);
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &select_db_zval, number_of_arguments, arguments);
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&select_db_zval);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+       zval *select_db_zval=NULL;
+
+       arguments[0]=host;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_pconnect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+
+       number_of_arguments=2;
+       arguments[0]=db;
+       arguments[1]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_select_db", &select_db_zval, number_of_arguments, arguments);
+       if (!select_db_zval || (select_db_zval->type==IS_BOOL && select_db_zval->value.lval==0) ) {
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               /* also close connection */
+               number_of_arguments=1;
+               arguments[0]=&returned_zval;
+               zend_list_addref(returned_zval->value.lval);
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &select_db_zval, number_of_arguments, arguments);
+               if (select_db_zval) zval_ptr_dtor(&select_db_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&select_db_zval);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_close", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_BOOL) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+
+       arguments[0]=db_name;
+       arguments[1]=sql_statement;
+       arguments[2]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_db_query", &returned_zval, number_of_arguments, arguments);
+       /* mysql_query returns a bool for success or failure, or a result_identifier for select statements */
+       if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_num_fields", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_LONG) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_field_name", &returned_zval, number_of_arguments, arguments);
+       /* mysql_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_field_type", &returned_zval, number_of_arguments, arguments);
+       /* mysql_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_resulttype=NULL;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_resulttype);
+       ZVAL_LONG(zval_resulttype, MYSQL_NUM);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_resulttype;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_fetch_array", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_ARRAY) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_resulttype);
+               return 0;
+       }
+       FREE_ZVAL(zval_resulttype);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_mysql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns string */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       if (!dbx_handle) number_of_arguments=0;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "mysql_error", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
 /*
  * Local variables:
index fcfd348d5ffe2c2ff8d25b8c074a4bacb6ecd151..e0b4ef1fe2f9fa22a453837a9a5e2f82c90ef10b 100644 (file)
 #include "php.h"
 
 int dbx_mysql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int dbx_mysql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
 int dbx_mysql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int dbx_mysql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
 int dbx_mysql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int dbx_mysql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int dbx_mysql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int dbx_mysql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int dbx_mysql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns string */
+       /* returns string */
 
-#endif /* ZEND_DBX_MYSQL_H */
+#endif /* ZEND_DBX_MYSQL_H */
 
 /*
  * Local variables:
index 6d9830491f28e0507b8d8080d4dd4b1b97993d86..b0ccb8ac8974bd906660a8deefe9d652887b1549 100644 (file)
 #include "dbx.h"
 #include "dbx_oci8.h"
 
-#define OCI_ASSOC      1<<0
-#define OCI_NUM                1<<1
-#define OCI_RETURN_NULLS               1<<2
-#define OCI_RETURN_LOBS        1<<3
-
-int dbx_oci8_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-
-    arguments[0]=username;
-    arguments[1]=password;
-    arguments[2]=db;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCILogon", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
-
-    arguments[0]=username;
-    arguments[1]=password;
-    arguments[2]=db;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIPLogon", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCILogOff", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_BOOL) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * returned_zval=NULL;
-    zval * execute_zval=NULL;
-
-    arguments[0]=dbx_handle;
-    arguments[1]=sql_statement;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIParse", &returned_zval, number_of_arguments, arguments);
-    /* OCIParse returns a bool for failure, or a statement_identifier for valid sql_statements */
-    if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    number_of_arguments=1;
-    arguments[0]=&returned_zval;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIExecute", &execute_zval, number_of_arguments, arguments);
-    /* OCIExecute returns a bool for success or failure???? */
-    if (!execute_zval || execute_zval->type!=IS_BOOL) {
-        if (execute_zval) zval_ptr_dtor(&execute_zval);
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-count as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCINumCols", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_LONG) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-name as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    /* dbx uses 0-based column-indices, oci8 uses 1-based indices... */
-    ZVAL_LONG(zval_column_index, column_index+1);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIColumnName", &returned_zval, number_of_arguments, arguments);
-    /* OCIColumnName returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-type as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    /* dbx uses 0-based column-indices, oci8 uses 1-based indices... */
-    ZVAL_LONG(zval_column_index, column_index+1);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIColumnType", &returned_zval, number_of_arguments, arguments);
-    /* OCIColumnType returns a string??? */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
-
-int dbx_oci8_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * zval_resulttype=NULL;
-    zval * zval_returned_array=NULL;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_resulttype);
-    ZVAL_LONG(zval_resulttype, OCI_NUM | OCI_RETURN_NULLS);/* no ASSOC, dbx handles that part */
-    arguments[0]=result_handle;
-    arguments[1]=&zval_returned_array;
-    arguments[2]=&zval_resulttype;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIFetchInto", &returned_zval, number_of_arguments, arguments);
-    /* OCIFetchInto returns an integer, but the actual array is passed back in arg[1] */
-    /* I'm not sure how this will work, Thies, so this is something that should be especially tested! */
-    if (!returned_zval || returned_zval->type!=IS_BOOL || returned_zval->value.lval==0) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_resulttype);
-        return 0;
-        }
-    FREE_ZVAL(zval_resulttype);
-    zval_ptr_dtor(&returned_zval);
-    MOVE_RETURNED_TO_RV(rv, zval_returned_array);
-    return 1;
-    }
-
-int dbx_oci8_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns string */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-    zval * returned_message_zval=NULL;
-    arguments[0]=dbx_handle;
-    if (!dbx_handle) number_of_arguments=0;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIError", &returned_zval, number_of_arguments, arguments);
-    /* OCIError should returns an assoc array containing code & message, dbx needs the message */
-    if (!returned_zval || returned_zval->type!=IS_ARRAY) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    /* get the messagestring here */
-    if (zend_hash_find(returned_zval->value.ht, "message", strlen("message")+1, (void **) &returned_message_zval)==FAILURE) {
-        /* oops! no msg? */
-        zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_message_zval);
-    zval_ptr_dtor(&returned_zval);
-    return 1;
-    }
+#define OCI_ASSOC        1<<0
+#define OCI_NUM          1<<1
+#define OCI_RETURN_NULLS 1<<2
+#define OCI_RETURN_LOBS  1<<3
+
+int dbx_oci8_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+
+       arguments[0]=username;
+       arguments[1]=password;
+       arguments[2]=db;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCILogon", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
+
+       arguments[0]=username;
+       arguments[1]=password;
+       arguments[2]=db;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIPLogon", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCILogOff", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_BOOL) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *returned_zval=NULL;
+       zval *execute_zval=NULL;
+
+       arguments[0]=dbx_handle;
+       arguments[1]=sql_statement;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIParse", &returned_zval, number_of_arguments, arguments);
+       /* OCIParse returns a bool for failure, or a statement_identifier for valid sql_statements */
+       if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       number_of_arguments=1;
+       arguments[0]=&returned_zval;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIExecute", &execute_zval, number_of_arguments, arguments);
+       /* OCIExecute returns a bool for success or failure???? */
+       if (!execute_zval || execute_zval->type!=IS_BOOL) {
+               if (execute_zval) zval_ptr_dtor(&execute_zval);
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCINumCols", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_LONG) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       /* dbx uses 0-based column-indices, oci8 uses 1-based indices... */
+       ZVAL_LONG(zval_column_index, column_index+1);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIColumnName", &returned_zval, number_of_arguments, arguments);
+       /* OCIColumnName returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       /* dbx uses 0-based column-indices, oci8 uses 1-based indices... */
+       ZVAL_LONG(zval_column_index, column_index+1);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIColumnType", &returned_zval, number_of_arguments, arguments);
+       /* OCIColumnType returns a string??? */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
+
+int dbx_oci8_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *zval_resulttype=NULL;
+       zval *zval_returned_array=NULL;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_resulttype);
+       ZVAL_LONG(zval_resulttype, OCI_NUM | OCI_RETURN_NULLS); /* no ASSOC, dbx handles that part */
+       arguments[0]=result_handle;
+       arguments[1]=&zval_returned_array;
+       arguments[2]=&zval_resulttype;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIFetchInto", &returned_zval, number_of_arguments, arguments);
+       /* OCIFetchInto returns an integer, but the actual array is passed back in arg[1] */
+       /* I'm not sure how this will work, Thies, so this is something that should be especially tested! */
+       if (!returned_zval || returned_zval->type!=IS_BOOL || returned_zval->value.lval==0) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_resulttype);
+               return 0;
+       }
+       FREE_ZVAL(zval_resulttype);
+       zval_ptr_dtor(&returned_zval);
+       MOVE_RETURNED_TO_RV(rv, zval_returned_array);
+       return 1;
+}
+
+int dbx_oci8_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns string */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
+       zval *returned_message_zval=NULL;
+       arguments[0]=dbx_handle;
+       if (!dbx_handle) number_of_arguments=0;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIError", &returned_zval, number_of_arguments, arguments);
+       /* OCIError should returns an assoc array containing code & message, dbx needs the message */
+       if (!returned_zval || returned_zval->type!=IS_ARRAY) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       /* get the messagestring here */
+       if (zend_hash_find(returned_zval->value.ht, "message", strlen("message")+1, (void **) &returned_message_zval)==FAILURE) {
+               /* oops! no msg? */
+               zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_message_zval);
+       zval_ptr_dtor(&returned_zval);
+       return 1;
+}
 
 /*
  * Local variables:
index b7d76dd43d850a8894005fb5292a67064eb9a5ee..d8dd6173224de142abdac1da28dba6371354910c 100644 (file)
 #include "php.h"
 
 int dbx_oci8_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int dbx_oci8_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
 int dbx_oci8_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int dbx_oci8_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
 int dbx_oci8_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int dbx_oci8_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int dbx_oci8_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int dbx_oci8_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int dbx_oci8_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns string */
+       /* returns string */
 
 #endif /* ZEND_DBX_OCI8_H */
 
index f8bfe7b2b504574a9308e30e87b5923911c248eb..1bb593bea18b7d9df4824fa5e60fe97e44b29c71 100644 (file)
 #include "dbx.h"
 #include "dbx_odbc.h"
 
-#define ODBC_ASSOC     1
-#define ODBC_NUM        2 
+#define ODBC_ASSOC    1
+#define ODBC_NUM      2
 
-int dbx_odbc_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
+int dbx_odbc_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
 
-    arguments[0]=db;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_connect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       arguments[0]=db;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_connect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int number_of_arguments=3;
-    zval **arguments[3];
-    zval * returned_zval=NULL;
+int dbx_odbc_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int number_of_arguments=3;
+       zval **arguments[3];
+       zval *returned_zval=NULL;
 
-    arguments[0]=db;
-    arguments[1]=username;
-    arguments[2]=password;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_pconnect", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       arguments[0]=db;
+       arguments[1]=username;
+       arguments[2]=password;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_pconnect", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
+int dbx_odbc_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
        int exit_status=EG(exit_status);
 
        int actual_resource_type;
        void *resource;
-       resource = zend_list_find((*dbx_handle)->value.lval, &actual_resource_type);
-    if (!resource) {
-        return 0;
-        }
+       resource = zend_list_find((*dbx_handle)->value.lval, &actual_resource_type);
+       if (!resource) {
+               return 0;
+       }
 
-    arguments[0]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_close", &returned_zval, number_of_arguments, arguments);
+       arguments[0]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_close", &returned_zval, number_of_arguments, arguments);
 
-    if (!returned_zval || returned_zval->type!=IS_NULL) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    convert_to_long_ex(&returned_zval);
-    returned_zval->value.lval=1;
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       if (!returned_zval || returned_zval->type!=IS_NULL) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       convert_to_long_ex(&returned_zval);
+       returned_zval->value.lval=1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * queryresult_zval=NULL;
-    zval * num_fields_zval=NULL;
+int dbx_odbc_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *queryresult_zval=NULL;
+       zval *num_fields_zval=NULL;
 
-    /* db_name is not used in this function */
-    arguments[0]=dbx_handle;
-    arguments[1]=sql_statement;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_exec", &queryresult_zval, number_of_arguments, arguments);
-    /* odbc_query returns a bool for failure, or a result_identifier for success */
-    if (!queryresult_zval || queryresult_zval->type!=IS_RESOURCE) {
-        if (queryresult_zval) zval_ptr_dtor(&queryresult_zval);
-        return 0;
-        }
-    MAKE_STD_ZVAL(num_fields_zval);
-    ZVAL_LONG(num_fields_zval, 0);
-    if (!dbx_odbc_getcolumncount(&num_fields_zval, &queryresult_zval, INTERNAL_FUNCTION_PARAM_PASSTHRU)) {
-        FREE_ZVAL(num_fields_zval);
-        if (queryresult_zval) zval_ptr_dtor(&queryresult_zval);
-        return 0;
-        }
-    if (num_fields_zval->value.lval==0) {
-        (*rv)->type=IS_BOOL;
-        (*rv)->value.lval=1; /* success, but no data */
-        FREE_ZVAL(num_fields_zval);
-        if (queryresult_zval) zval_ptr_dtor(&queryresult_zval);
-        return 1;
-        }
-    FREE_ZVAL(num_fields_zval);
-    MOVE_RETURNED_TO_RV(rv, queryresult_zval);
-    return 1;
-    }
+       /* db_name is not used in this function */
+       arguments[0]=dbx_handle;
+       arguments[1]=sql_statement;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_exec", &queryresult_zval, number_of_arguments, arguments);
+       /* odbc_query returns a bool for failure, or a result_identifier for success */
+       if (!queryresult_zval || queryresult_zval->type!=IS_RESOURCE) {
+               if (queryresult_zval) zval_ptr_dtor(&queryresult_zval);
+               return 0;
+       }
+       MAKE_STD_ZVAL(num_fields_zval);
+       ZVAL_LONG(num_fields_zval, 0);
+       if (!dbx_odbc_getcolumncount(&num_fields_zval, &queryresult_zval, INTERNAL_FUNCTION_PARAM_PASSTHRU)) {
+               FREE_ZVAL(num_fields_zval);
+               if (queryresult_zval) zval_ptr_dtor(&queryresult_zval);
+               return 0;
+       }
+       if (num_fields_zval->value.lval==0) {
+               (*rv)->type=IS_BOOL;
+               (*rv)->value.lval=1; /* success, but no data */
+               FREE_ZVAL(num_fields_zval);
+               if (queryresult_zval) zval_ptr_dtor(&queryresult_zval);
+               return 1;
+       }
+       FREE_ZVAL(num_fields_zval);
+       MOVE_RETURNED_TO_RV(rv, queryresult_zval);
+       return 1;
+}
 
-int dbx_odbc_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-count as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
+int dbx_odbc_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
 
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_num_fields", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_LONG || returned_zval->value.lval<0) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_num_fields", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_LONG || returned_zval->value.lval<0) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-name as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
+int dbx_odbc_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
 
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index+1);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_field_name", &returned_zval, number_of_arguments, arguments);
-    /* odbc_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index+1);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_field_name", &returned_zval, number_of_arguments, arguments);
+       /* odbc_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-type as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
+int dbx_odbc_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
 
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index+1);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_field_type", &returned_zval, number_of_arguments, arguments);
-    /* odbc_field_name returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index+1);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_field_type", &returned_zval, number_of_arguments, arguments);
+       /* odbc_field_name returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
 
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    int number_of_arguments;
-    zval **arguments[2];
-    zval * num_fields_zval=NULL;
-    zval * fetch_row_result_zval=NULL;
-    zval * field_result_zval=NULL;
-    zval * field_index_zval;
-    zval * returned_zval=NULL;
-    long field_index;
-    long field_count=-1;
+int dbx_odbc_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       int number_of_arguments;
+       zval **arguments[2];
+       zval *num_fields_zval=NULL;
+       zval *fetch_row_result_zval=NULL;
+       zval *field_result_zval=NULL;
+       zval *field_index_zval;
+       zval *returned_zval=NULL;
+       long field_index;
+       long field_count=-1;
 
-    /* get # fields */
-    MAKE_STD_ZVAL(num_fields_zval);
-    ZVAL_LONG(num_fields_zval, 0);
-    if (!dbx_odbc_getcolumncount(&num_fields_zval, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU)) {
-        return 0;
-        }
-    field_count=num_fields_zval->value.lval;
-    FREE_ZVAL(num_fields_zval);
-    /* fetch row */
-    number_of_arguments=1;
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_fetch_row", &fetch_row_result_zval, number_of_arguments, arguments);
-    if (!fetch_row_result_zval || fetch_row_result_zval->type!=IS_BOOL) {
-        if (fetch_row_result_zval) zval_ptr_dtor(&fetch_row_result_zval);
-        return 0;
-        }
-    if (fetch_row_result_zval->value.lval==0) {
-        (*rv)->type=IS_LONG;
-        (*rv)->value.lval=0; /* ok, no more rows */
-        zval_ptr_dtor(&fetch_row_result_zval);
-        return 0;
-        }
-    zval_ptr_dtor(&fetch_row_result_zval);
-    /* fill array with field results... */
-    MAKE_STD_ZVAL(returned_zval);
-    if (array_init(returned_zval) != SUCCESS) {
-        zend_error(E_ERROR, "dbx_odbc_getrow: unable to create result-array...");
-        FREE_ZVAL(returned_zval);
-        return 0;
-        }
-    MAKE_STD_ZVAL(field_index_zval);
-    ZVAL_LONG(field_index_zval, 0);
-    number_of_arguments=2;
-    for (field_index=0; field_index<field_count; ++field_index) {
-        ZVAL_LONG(field_index_zval, field_index+1);
-        arguments[0]=result_handle;
-        arguments[1]=&field_index_zval;
-        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_result", &field_result_zval, number_of_arguments, arguments);
-        zend_hash_index_update(returned_zval->value.ht, field_index, (void *)&(field_result_zval), sizeof(zval *), NULL);
-        }
-    FREE_ZVAL(field_index_zval);
+       /* get # fields */
+       MAKE_STD_ZVAL(num_fields_zval);
+       ZVAL_LONG(num_fields_zval, 0);
+       if (!dbx_odbc_getcolumncount(&num_fields_zval, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU)) {
+               return 0;
+       }
+       field_count=num_fields_zval->value.lval;
+       FREE_ZVAL(num_fields_zval);
+       /* fetch row */
+       number_of_arguments=1;
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_fetch_row", &fetch_row_result_zval, number_of_arguments, arguments);
+       if (!fetch_row_result_zval || fetch_row_result_zval->type!=IS_BOOL) {
+               if (fetch_row_result_zval) zval_ptr_dtor(&fetch_row_result_zval);
+               return 0;
+       }
+       if (fetch_row_result_zval->value.lval==0) {
+               (*rv)->type=IS_LONG;
+               (*rv)->value.lval=0; /* ok, no more rows */
+               zval_ptr_dtor(&fetch_row_result_zval);
+               return 0;
+       }
+       zval_ptr_dtor(&fetch_row_result_zval);
+       /* fill array with field results... */
+       MAKE_STD_ZVAL(returned_zval);
+       if (array_init(returned_zval) != SUCCESS) {
+               zend_error(E_ERROR, "dbx_odbc_getrow: unable to create result-array...");
+               FREE_ZVAL(returned_zval);
+               return 0;
+       }
+       MAKE_STD_ZVAL(field_index_zval);
+       ZVAL_LONG(field_index_zval, 0);
+       number_of_arguments=2;
+       for (field_index=0; field_index<field_count; ++field_index) {
+               ZVAL_LONG(field_index_zval, field_index+1);
+               arguments[0]=result_handle;
+               arguments[1]=&field_index_zval;
+               dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_result", &field_result_zval, number_of_arguments, arguments);
+               zend_hash_index_update(returned_zval->value.ht, field_index, (void *)&(field_result_zval), sizeof(zval *), NULL);
+       }
+       FREE_ZVAL(field_index_zval);
 
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_odbc_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns string */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
+int dbx_odbc_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns string */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
 
-    arguments[0]=dbx_handle;
-    if (!dbx_handle) number_of_arguments=0;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_errormsg", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       arguments[0]=dbx_handle;
+       if (!dbx_handle) number_of_arguments=0;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_errormsg", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
 /*
  * Local variables:
index fc50bc7b92644f1139bddfae38f3b133d02641ac..8af0a9cfbd35c46f584abbcc3691b77c9a4ffee7 100644 (file)
 #include "php.h"
 
 int dbx_odbc_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int dbx_odbc_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns persisten connection handle as resource on success or 0 as long on failure */
+       /* returns persisten connection handle as resource on success or 0 as long on failure */
 int dbx_odbc_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int dbx_odbc_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
 int dbx_odbc_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int dbx_odbc_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int dbx_odbc_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int dbx_odbc_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int dbx_odbc_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns string */
+       /* returns string */
 
-#endif /* ZEND_DBX_ODBC_H */
+#endif /* ZEND_DBX_ODBC_H */
 
 /*
  * Local variables:
index b25ea986abeddcb2198c7af39e51e399b24d78dd..a646b8b0c549a8ed94a56f2c38132ba4410662a1 100644 (file)
 #include "dbx_pgsql.h"
 #include <string.h>
 
-#define PGSQL_ASSOC            1<<0
-#define PGSQL_NUM              1<<1
+#define PGSQL_ASSOC    1<<0
+#define PGSQL_NUM      1<<1
 
-int dbx_pgsql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns connection handle as resource on success or 0 as long on failure */
-    int nargs=5;
+int dbx_pgsql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns connection handle as resource on success or 0 as long on failure */
+       int nargs=5;
        char *port="5432", *connstring=NULL;
-    zval **args[5], *rarg = NULL;
+       zval **args[5], *rarg = NULL;
        zval *conn_zval = NULL;
-    zval *returned_zval=NULL;
+       zval *returned_zval=NULL;
 
        MAKE_STD_ZVAL(conn_zval);
-    ZVAL_LONG(conn_zval, 0);
+       ZVAL_LONG(conn_zval, 0);
 
-       if (Z_STRLEN_PP(username)>0 && Z_STRLEN_PP(password)>0){
+       if (Z_STRLEN_PP(username)>0 && Z_STRLEN_PP(password)>0) {
                int len;
 
                len = Z_STRLEN_PP(host)+Z_STRLEN_PP(db)+strlen(port);
@@ -62,27 +63,27 @@ int dbx_pgsql_connect(zval **rv, zval **host, zval **db, zval **username, zval *
        }
        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_connect", &returned_zval, nargs, args);             
 
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-       
-    return 1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
-int dbx_pgsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
-    int nargs=5;
+int dbx_pgsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
+       int nargs=5;
        char *port="5432", *connstring=NULL;
-    zval **args[5], *rarg = NULL;
+       zval **args[5], *rarg = NULL;
        zval *conn_zval = NULL;
-    zval *returned_zval=NULL;
+       zval *returned_zval=NULL;
 
        MAKE_STD_ZVAL(conn_zval);
-    ZVAL_LONG(conn_zval, 0);
+       ZVAL_LONG(conn_zval, 0);
 
-       if (Z_STRLEN_PP(username)>0 && Z_STRLEN_PP(password)>0){
+       if (Z_STRLEN_PP(username)>0 && Z_STRLEN_PP(password)>0) {
                int len;
 
                len = Z_STRLEN_PP(host)+Z_STRLEN_PP(db)+strlen(port);
@@ -105,164 +106,169 @@ int dbx_pgsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval
                }
                args[4] = db;
        }
-       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_pconnect", &returned_zval, nargs, args);            
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_pconnect", &returned_zval, nargs, args);
 
-    if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
+       if (!returned_zval || returned_zval->type!=IS_RESOURCE) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-       
-    return 1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
-int dbx_pgsql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
+int dbx_pgsql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
 
-    arguments[0]=dbx_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_close", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_BOOL) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
+       arguments[0]=dbx_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_close", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_BOOL) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
-int dbx_pgsql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns 1 as long or a result identifier as resource on success  
+int dbx_pgsql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns 1 as long or a result identifier as resource on success  
           or 0 as long on failure */
-    int nargs=2;
-    zval **args[2];
-    zval *returned_zval=NULL, *num_rows_zval=NULL;
-
-    /* db_name is not used in this function */
-    args[0]=dbx_handle;
-    args[1]=sql_statement;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_exec", &returned_zval, nargs, args);
-    /* pg_query returns a bool for success or failure, 
+       int nargs=2;
+       zval **args[2];
+       zval *returned_zval=NULL, *num_rows_zval=NULL;
+
+       /* db_name is not used in this function */
+       args[0]=dbx_handle;
+       args[1]=sql_statement;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_exec", &returned_zval, nargs, args);
+       /* pg_query returns a bool for success or failure, 
           or a result_identifier for select statements */
        if (!returned_zval || (returned_zval->type!=IS_BOOL && returned_zval->type!=IS_RESOURCE)) {
                if (returned_zval) zval_ptr_dtor(&returned_zval);
                return 0;
        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-
-    return 1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
-int dbx_pgsql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-count as long on success or 0 as long on failure */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
-
-    arguments[0]=result_handle;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_numfields", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_LONG) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
-        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+int dbx_pgsql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-count as long on success or 0 as long on failure */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
 
-int dbx_pgsql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-name as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
-
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fieldname", &returned_zval, number_of_arguments, arguments);
-    /* pg_fieldname returns a string */
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
-        }
-    FREE_ZVAL(zval_column_index);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
-    }
+       arguments[0]=result_handle;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_numfields", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_LONG) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
+       }
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-int dbx_pgsql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns column-type as string on success or 0 as long on failure */
-    int number_of_arguments=2;
-    zval **arguments[2];
-    zval * zval_column_index;
-    zval * returned_zval=NULL;
+int dbx_pgsql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-name as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fieldname", &returned_zval, number_of_arguments, arguments);
+       /* pg_fieldname returns a string */
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
+       }
+       FREE_ZVAL(zval_column_index);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
+}
 
-    MAKE_STD_ZVAL(zval_column_index);
-    ZVAL_LONG(zval_column_index, column_index);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_column_index;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fieldtype", &returned_zval, number_of_arguments, arguments);
-    /* pg_fieldtype returns a string */
+int dbx_pgsql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns column-type as string on success or 0 as long on failure */
+       int number_of_arguments=2;
+       zval **arguments[2];
+       zval *zval_column_index;
+       zval *returned_zval=NULL;
+
+       MAKE_STD_ZVAL(zval_column_index);
+       ZVAL_LONG(zval_column_index, column_index);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_column_index;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fieldtype", &returned_zval, number_of_arguments, arguments);
+       /* pg_fieldtype returns a string */
        if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_column_index);
-        return 0;
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_column_index);
+               return 0;
        }
-    FREE_ZVAL(zval_column_index);
+       FREE_ZVAL(zval_column_index);
 
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
-int dbx_pgsql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
-    int number_of_arguments=2;
+int dbx_pgsql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       int number_of_arguments=2;
        int save_error_reporting=0;
-    zval **arguments[2];
-    zval * zval_row=NULL;
-    zval * returned_zval=NULL;
+       zval **arguments[2];
+       zval *zval_row=NULL;
+       zval *returned_zval=NULL;
        
-    MAKE_STD_ZVAL(zval_row);
-    ZVAL_LONG(zval_row, row_number);
-    arguments[0]=result_handle;
-    arguments[1]=&zval_row;
+       MAKE_STD_ZVAL(zval_row);
+       ZVAL_LONG(zval_row, row_number);
+       arguments[0]=result_handle;
+       arguments[1]=&zval_row;
 
-    if (EG(error_reporting) & E_WARNING){
+       if (EG(error_reporting) & E_WARNING){
                save_error_reporting = EG(error_reporting);
                EG(error_reporting) &= ~E_WARNING;
        }
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fetch_array", &returned_zval, number_of_arguments, arguments);
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fetch_array", &returned_zval, number_of_arguments, arguments);
        if (save_error_reporting) {
                EG(error_reporting) = save_error_reporting;
        }
-    if (!returned_zval || returned_zval->type!=IS_ARRAY) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        FREE_ZVAL(zval_row);
-        return 0;
+       if (!returned_zval || returned_zval->type!=IS_ARRAY) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               FREE_ZVAL(zval_row);
+               return 0;
        }
-    FREE_ZVAL(zval_row);
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
+       FREE_ZVAL(zval_row);
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
-int dbx_pgsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) {
-    /* returns string */
-    int number_of_arguments=1;
-    zval **arguments[1];
-    zval * returned_zval=NULL;
+int dbx_pgsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS)
+{
+       /* returns string */
+       int number_of_arguments=1;
+       zval **arguments[1];
+       zval *returned_zval=NULL;
 
-    arguments[0]=dbx_handle;
-    if (!dbx_handle) number_of_arguments=0;
-    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_errormessage", &returned_zval, number_of_arguments, arguments);
-    if (!returned_zval || returned_zval->type!=IS_STRING) {
-        if (returned_zval) zval_ptr_dtor(&returned_zval);
-        return 0;
+       arguments[0]=dbx_handle;
+       if (!dbx_handle) number_of_arguments=0;
+       dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_errormessage", &returned_zval, number_of_arguments, arguments);
+       if (!returned_zval || returned_zval->type!=IS_STRING) {
+               if (returned_zval) zval_ptr_dtor(&returned_zval);
+               return 0;
        }
-    MOVE_RETURNED_TO_RV(rv, returned_zval);
-    return 1;
+       MOVE_RETURNED_TO_RV(rv, returned_zval);
+       return 1;
 }
 
 /*
index 06bb56ef2f673588b8285e24a71e6e3219ba4802..43d76fcac6dd797270aee57a12809cd3436017a4 100644 (file)
 #include "php.h"
 
 int dbx_pgsql_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns connection handle as resource on success or 0 as long on failure */
+       /* returns connection handle as resource on success or 0 as long on failure */
 int dbx_pgsql_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns persistent connection handle as resource on success or 0 as long on failure */
+       /* returns persistent connection handle as resource on success or 0 as long on failure */
 int dbx_pgsql_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long on success or 0 as long on failure */
+       /* returns 1 as long on success or 0 as long on failure */
 int dbx_pgsql_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
+       /* returns 1 as long or a result identifier as resource on success  or 0 as long on failure */
 int dbx_pgsql_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-count as long on success or 0 as long on failure */
+       /* returns column-count as long on success or 0 as long on failure */
 int dbx_pgsql_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-name as string on success or 0 as long on failure */
+       /* returns column-name as string on success or 0 as long on failure */
 int dbx_pgsql_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns column-type as string on success or 0 as long on failure */
+       /* returns column-type as string on success or 0 as long on failure */
 int dbx_pgsql_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
+       /* returns array[0..columncount-1] as strings on success or 0 as long on failure */
 int dbx_pgsql_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
-    /* returns string */
+       /* returns string */
 
-#endif /* ZEND_DBX_PGSQL_H */
+#endif /* ZEND_DBX_PGSQL_H */
 
 /*
  * Local variables:
index 71cf5c2609061ed542f7cfc60c60ee17b782944e..baf8f7ed6723fbb3925d2a6969e11034d0bc0706 100644 (file)
@@ -54,8 +54,8 @@ ZEND_FUNCTION(dbx_sort);
 ZEND_FUNCTION(dbx_compare);
 
 /* 
-       Declare any global variables you may need between the BEGIN
-       and END macros here:     
+   Declare any global variables you may need between the BEGIN
+   and END macros here:     
 */
 
 /*
@@ -76,7 +76,7 @@ ZEND_END_MODULE_GLOBALS(dbx)
 #define DBXG(v) (dbx_globals.v)
 #endif
 
-#endif /* ZEND_PHP_DBX_H */
+#endif /* ZEND_PHP_DBX_H */
 
 
 /*