]> granicus.if.org Git - php/commitdiff
fixed memleaks in bind functions
authorGeorg Richter <georg@php.net>
Tue, 9 Mar 2004 12:01:23 +0000 (12:01 +0000)
committerGeorg Richter <georg@php.net>
Tue, 9 Mar 2004 12:01:23 +0000 (12:01 +0000)
added 4.1.2 support (renamed functions)

ext/mysqli/config.m4
ext/mysqli/mysqli_api.c
ext/mysqli/mysqli_fe.c
ext/mysqli/php_mysqli.h

index cddc55f1499f75dccc7451daf7aec4d6c88803ed..d611d633b17f15f362f2b8632fd8fe7a0b0836e1 100644 (file)
@@ -39,11 +39,15 @@ if test "$PHP_MYSQLI" != "no"; then
   dnl
   dnl Check the library
   dnl
-  PHP_CHECK_LIBRARY(mysqlclient, mysql_bind_param,
+  PHP_CHECK_LIBRARY(mysqlclient, mysql_set_server_option,
   [
     PHP_EVAL_INCLINE($MYSQLI_INCLINE)
     PHP_EVAL_LIBLINE($MYSQLI_LIBLINE, MYSQLI_SHARED_LIBADD)
     AC_DEFINE(HAVE_MYSQLILIB,1,[ ])
+    PHP_CHECK_LIBRARY(mysqlclient, mysql_bind_param,
+    [
+       AC_DEFINE(HAVE_MYSQLI_OLDAPI,1,[ ])
+    ],[],[])
   ],[
     AC_MSG_ERROR([wrong mysql library version or lib not found. Check config.log for more information.])
   ],[
index 57d7e8094319e25a058ea7398412d93b39265f11..876b39afc9bbc35bfef84b803905e77f243e7638 100644 (file)
@@ -68,9 +68,9 @@ PHP_FUNCTION(mysqli_autocommit)
 }
 /* }}} */
 
-/* {{{ proto bool mysqli_bind_param(object stmt, string types, mixed variable [,mixed,....])
+/* {{{ proto bool mysqli_stmt_bind_param(object stmt, string types, mixed variable [,mixed,....])
    Bind variables to a prepared statement as parameters */
-PHP_FUNCTION(mysqli_bind_param)
+PHP_FUNCTION(mysqli_stmt_bind_param)
 {
        zval                    ***args;
        int                     argc = ZEND_NUM_ARGS();
@@ -170,8 +170,11 @@ PHP_FUNCTION(mysqli_bind_param)
                }
                ofs++;
        }
-       
+#ifndef HAVE_MYSQLI_OLDAPI     
+       rc = mysql_stmt_bind_param(stmt->stmt, bind);
+#else
        rc = mysql_bind_param(stmt->stmt, bind);
+#endif
        MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
 
        if (rc) {
@@ -197,14 +200,14 @@ PHP_FUNCTION(mysqli_bind_param)
 }
 /* }}} */
 
-/* {{{ proto bool mysqli_bind_result(object stmt, mixed var, [,mixed, ...])
+/* {{{ proto bool mysqli_stmt_bind_result(object stmt, mixed var, [,mixed, ...])
    Bind variables to a prepared statement for result storage */
 
 /* TODO:
    do_alloca, free_alloca
 */
 
-PHP_FUNCTION(mysqli_bind_result)
+PHP_FUNCTION(mysqli_stmt_bind_result)
 {
        zval            ***args;
        int             argc = ZEND_NUM_ARGS();
@@ -243,6 +246,7 @@ PHP_FUNCTION(mysqli_bind_result)
 
        if (var_cnt != stmt->stmt->field_count) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of bind variables doesn't match number of fields in prepared statmement.");
+               efree(args);
                RETURN_FALSE;
        }
 
@@ -266,9 +270,12 @@ PHP_FUNCTION(mysqli_bind_result)
                        case MYSQL_TYPE_FLOAT:
                                convert_to_double_ex(args[i]);
                                stmt->result.buf[ofs].type = IS_DOUBLE;
-                               stmt->result.buf[ofs].buflen = 0;
+                               stmt->result.buf[ofs].buflen = sizeof(double);
+                               
+                               /* allocate buffer for double */
+                               stmt->result.buf[ofs].val = (char *)emalloc(sizeof(double));
                                bind[ofs].buffer_type = MYSQL_TYPE_DOUBLE;
-                               bind[ofs].buffer = (gptr)&Z_DVAL_PP(args[i]);
+                               bind[ofs].buffer = stmt->result.buf[ofs].val;
                                bind[ofs].is_null = &stmt->result.is_null[ofs];
                                break;
 
@@ -280,17 +287,18 @@ PHP_FUNCTION(mysqli_bind_result)
                                convert_to_long_ex(args[i]);
                                stmt->result.buf[ofs].type = IS_LONG;
                                stmt->result.buf[ofs].buflen = 0;
+                               stmt->result.buf[ofs].val = (char *)emalloc(sizeof(long));
                                bind[ofs].buffer_type = MYSQL_TYPE_LONG;
-                               bind[ofs].buffer = (gptr)&Z_LVAL_PP(args[i]);
+                               bind[ofs].buffer = stmt->result.buf[ofs].val;
                                bind[ofs].is_null = &stmt->result.is_null[ofs];
                                break;
 
                        case MYSQL_TYPE_LONGLONG:
                                stmt->result.buf[ofs].type = IS_STRING; 
                                stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); 
-                               stmt->result.buf[ofs].buffer = (char *)emalloc(stmt->result.buf[ofs].buflen);
+                               stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen);
                                bind[ofs].buffer_type = MYSQL_TYPE_LONGLONG;
-                               bind[ofs].buffer = stmt->result.buf[ofs].buffer;
+                               bind[ofs].buffer = stmt->result.buf[ofs].val;
                                bind[ofs].is_null = &stmt->result.is_null[ofs];
                                bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
                                break;
@@ -307,9 +315,9 @@ PHP_FUNCTION(mysqli_bind_result)
                                stmt->result.buf[ofs].type = IS_STRING; 
                                stmt->result.buf[ofs].buflen =
                                        (stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256: 256;
-                               stmt->result.buf[ofs].buffer = (char *)emalloc(stmt->result.buf[ofs].buflen);
+                               stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen);
                                bind[ofs].buffer_type = MYSQL_TYPE_STRING;
-                               bind[ofs].buffer = stmt->result.buf[ofs].buffer;
+                               bind[ofs].buffer = stmt->result.buf[ofs].val;
                                bind[ofs].is_null = &stmt->result.is_null[ofs];
                                bind[ofs].buffer_length = stmt->result.buf[ofs].buflen;
                                bind[ofs].length = &stmt->result.buf[ofs].buflen;
@@ -317,7 +325,11 @@ PHP_FUNCTION(mysqli_bind_result)
                }
        }
 
+#ifndef HAVE_MYSQLI_OLDAPI     
+       rc = mysql_stmt_bind_result(stmt->stmt, bind);
+#else
        rc = mysql_bind_result(stmt->stmt, bind);
+#endif
        MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
 
        if (rc) {
@@ -521,9 +533,9 @@ PHP_FUNCTION(mysqli_error)
 }
 /* }}} */
 
-/* {{{ proto bool mysqli_execute(object stmt)
+/* {{{ proto bool mysqli_stmt_execute(object stmt)
    Execute a prepared statement */
-PHP_FUNCTION(mysqli_execute)
+PHP_FUNCTION(mysqli_stmt_execute)
 {
        STMT                    *stmt;
        zval                    *mysql_stmt;
@@ -557,8 +569,11 @@ PHP_FUNCTION(mysqli_execute)
                        }       
                }
        }
-
+#ifndef HAVE_MYSQLI_OLDAPI     
+       if (mysql_stmt_execute(stmt->stmt)) {
+#else
        if (mysql_execute(stmt->stmt)) {
+#endif
                MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
                RETURN_FALSE;
        }
@@ -570,14 +585,18 @@ PHP_FUNCTION(mysqli_execute)
 }
 /* }}} */
 
-/* {{{ proto mixed mysqli_fetch(object stmt)
+/* {{{ proto mixed mysqli_stmt_fetch(object stmt)
    Fetch results from a prepared statement into the bound variables */
-PHP_FUNCTION(mysqli_fetch)
+PHP_FUNCTION(mysqli_stmt_fetch)
 {
        STMT                    *stmt;
        zval                    *mysql_stmt;
        unsigned int    i;
        ulong                   ret;
+       long                    lval;
+       double                  dval;
+       my_ulonglong    llval;
+       
 
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
                return;
@@ -589,41 +608,44 @@ PHP_FUNCTION(mysqli_fetch)
 
        for (i = 0; i < stmt->result.var_cnt; i++) {
                if (stmt->result.buf[i].type == IS_STRING) {
-                       memset(stmt->result.buf[i].buffer, 0, stmt->result.buf[i].buflen);
+                       memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen);
                }
        }
-       
+#ifndef HAVE_MYSQLI_OLDAPI     
+       if (!(ret = mysql_stmt_fetch(stmt->stmt))) {
+#else
        if (!(ret = mysql_fetch(stmt->stmt))) {
-
+#endif
                for (i = 0; i < stmt->result.var_cnt; i++) {
+                       if (stmt->result.vars[i]->type == IS_STRING && stmt->result.vars[i]->value.str.len) {
+                       efree(stmt->result.vars[i]->value.str.val);
+                       }
                        if (!stmt->result.is_null[i]) {
                                switch (stmt->result.buf[i].type) {
                                        case IS_LONG:
-                                               stmt->result.vars[i]->type = IS_LONG;
+                                               memcpy(&lval, stmt->result.buf[i].val, sizeof(long));
+                                               ZVAL_LONG(stmt->result.vars[i], lval);
                                                break;
                                        case IS_DOUBLE:
-                                               stmt->result.vars[i]->type = IS_DOUBLE;
+                                               memcpy(&dval, stmt->result.buf[i].val, sizeof(double));
+                                               ZVAL_DOUBLE(stmt->result.vars[i], dval);
                                                break;
                                        case IS_STRING:
                                                if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG) {
                                                        char tmp[50];
-                                                       my_ulonglong lval;
-                                                       memcpy (&lval, stmt->result.buf[i].buffer, sizeof(my_ulonglong));
-                                                       if (lval != (long)lval) {
+                                                       memcpy (&llval, stmt->result.buf[i].val, sizeof(my_ulonglong));
+                                                       if (llval != (long)llval) {
                                                                /* even though lval is declared as unsigned, the value
                                                                 * may be negative. Therefor we cannot use %llu and must
                                                                 * use %lld.
                                                                 */
-                                                               sprintf((char *)&tmp, "%lld", lval);
+                                                               sprintf((char *)&tmp, "%lld", llval);
                                                                ZVAL_STRING(stmt->result.vars[i], tmp, 1);
                                                        } else {
-                                                               ZVAL_LONG(stmt->result.vars[i], lval);
+                                                               ZVAL_LONG(stmt->result.vars[i], llval);
                                                        }
                                                } else {
-                                                       if (stmt->result.vars[i]->type == IS_STRING) {
-                                                               efree(stmt->result.vars[i]->value.str.val);
-                                                       } 
-                                                       ZVAL_STRING(stmt->result.vars[i], stmt->result.buf[i].buffer, 1); 
+                                                       ZVAL_STRING(stmt->result.vars[i], stmt->result.buf[i].val, 1); 
                                                }
                                                break;
                                        default:
@@ -1128,7 +1150,7 @@ PHP_FUNCTION(mysqli_options)
 
 /* {{{ proto int mysqli_param_count(object stmt) {
    Return the number of parameter for the given statement */
-PHP_FUNCTION(mysqli_param_count)
+PHP_FUNCTION(mysqli_stmt_param_count)
 {
        STMT            *stmt;
        zval            *mysql_stmt;
@@ -1138,7 +1160,11 @@ PHP_FUNCTION(mysqli_param_count)
        }
        MYSQLI_FETCH_RESOURCE(stmt, STMT *, &mysql_stmt, "mysqli_stmt"); 
                
+#ifndef HAVE_MYSQLI_OLDAPI     
+       RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
+#else
        RETURN_LONG(mysql_param_count(stmt->stmt));
+#endif
 }
 /* }}} */
 
@@ -1181,8 +1207,16 @@ PHP_FUNCTION(mysqli_prepare)
 
        stmt = (STMT *)ecalloc(1,sizeof(STMT));
 
+#ifdef HAVE_MYSQLI_OLDAPI
        stmt->stmt = mysql_prepare(mysql, query, query_len); 
-
+#else
+    if ((stmt->stmt = mysql_stmt_init(mysql))) {
+               if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
+                       mysql_stmt_close(stmt->stmt);
+                       stmt->stmt = NULL;
+               }
+       } 
+#endif
        if (!stmt->stmt) {
                MYSQLI_REPORT_MYSQL_ERROR(mysql);
                efree(stmt);
@@ -1195,31 +1229,6 @@ PHP_FUNCTION(mysqli_prepare)
 }
 /* }}} */
 
-/* {{{ proto mixed mysqli_get_metadata(object stmt)
-   return result set from statement */
-PHP_FUNCTION(mysqli_get_metadata)
-{
-       STMT                    *stmt;
-       MYSQL_RES               *result;
-       zval                    *mysql_stmt;
-       MYSQLI_RESOURCE *mysqli_resource;
-
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
-               return;
-       }
-       MYSQLI_FETCH_RESOURCE(stmt, STMT *, &mysql_stmt, "mysqli_stmt"); 
-       
-       if (!(result = mysql_get_metadata(stmt->stmt))){
-               MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
-               RETURN_FALSE;
-       }
-
-       mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
-       mysqli_resource->ptr = (void *)result;
-       MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);     
-}
-/* }}} */
-
 /* {{{ proto bool mysqli_real_connect(object link [,string hostname [,string username [,string passwd [,string dbname [,int port [,string socket [,int flags]]]]]]])
    Open a connection to a mysql server */ 
 PHP_FUNCTION(mysqli_real_connect)
@@ -1355,7 +1364,7 @@ PHP_FUNCTION(mysqli_rollback)
 
 /* {{{ proto bool mysqli_send_long_data(object stmt, int param_nr, string data)
 */
-PHP_FUNCTION(mysqli_send_long_data)
+PHP_FUNCTION(mysqli_stmt_send_long_data)
 {
        STMT    *stmt;
        zval    *mysql_stmt;
@@ -1372,8 +1381,11 @@ PHP_FUNCTION(mysqli_send_long_data)
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter number");
                RETURN_FALSE;
        }
-
+#ifndef HAVE_MYSQLI_OLDAPI     
+       if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
+#else
        if (mysql_send_long_data(stmt->stmt, param_nr, data, data_len)) {
+#endif
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -1605,6 +1617,85 @@ PHP_FUNCTION(mysqli_stmt_error)
 }
 /* }}} */
 
+#ifndef HAVE_MYSQLI_OLDAPI
+/* {{{ proto object mysqli_stmt_init(object link)
+   Initialize statement object
+*/
+PHP_FUNCTION(mysqli_stmt_init)
+{
+       MYSQL                   *mysql;
+       STMT                    *stmt;
+       zval                    *mysql_link;
+       MYSQLI_RESOURCE *mysqli_resource; 
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",&mysql_link, mysqli_link_class_entry) == FAILURE) {
+               return;
+       }
+       MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link");
+
+       if (!(stmt->stmt = mysql_stmt_init(mysql))) {
+               RETURN_FALSE;
+       }
+
+       mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
+       mysqli_resource->ptr = (void *)stmt;
+       MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_stmt_class_entry);
+}
+/* }}} */
+
+/* {{{ proto bool mysqli_stmt_prepare(object link, string query)
+   prepare server side statement with query
+*/
+PHP_FUNCTION(mysqli_stmt_prepare)
+{
+       STMT    *stmt;
+       zval    *mysql_stmt;
+       char    *query;
+       int             query_len;
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_stmt, mysqli_stmt_class_entry, &query, &query_len) == FAILURE) {
+               return;
+       }
+       MYSQLI_FETCH_RESOURCE(stmt, STMT *, &mysql_stmt, "mysqli_stmt");
+
+       if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
+               MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
+               RETURN_FALSE;
+       }
+       RETURN_TRUE;
+}
+/* }}} */
+#endif
+
+/* {{{ proto mixed mysqli_stmt_result_metadata(object stmt)
+   return result set from statement */
+PHP_FUNCTION(mysqli_stmt_result_metadata)
+{
+       STMT                    *stmt;
+       MYSQL_RES               *result;
+       zval                    *mysql_stmt;
+       MYSQLI_RESOURCE *mysqli_resource;
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
+               return;
+       }
+       MYSQLI_FETCH_RESOURCE(stmt, STMT *, &mysql_stmt, "mysqli_stmt"); 
+
+#ifndef HAVE_MYSQLI_OLDAPI     
+       if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
+#else
+       if (!(result = mysql_get_metadata(stmt->stmt))){
+#endif
+               MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
+               RETURN_FALSE;
+       }
+
+       mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
+       mysqli_resource->ptr = (void *)result;
+       MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);     
+}
+/* }}} */
+
 /* {{{ proto bool mysqli_stmt_store_result(stmt)
 */
 PHP_FUNCTION(mysqli_stmt_store_result)
index 8b75a34a020e52a5204ffb6bfcca67a14820d6b3..6c83c1df7114674a9d8df8336bbfd0c4de777af1 100644 (file)
@@ -53,12 +53,8 @@ static
 function_entry mysqli_functions[] = {
        PHP_FE(mysqli_affected_rows,                                            NULL)
        PHP_FE(mysqli_autocommit,                                                       NULL)
-       PHP_FE(mysqli_bind_param,                                                       third_arg_force_by_ref_rest)
-       PHP_FE(mysqli_bind_result,                                                      second_arg_force_by_ref_rest)
        PHP_FE(mysqli_change_user,                                                      NULL)
        PHP_FE(mysqli_character_set_name,                                       NULL)
-       PHP_FALIAS(mysqli_client_encoding, 
-                          mysqli_character_set_name,                           NULL)
        PHP_FE(mysqli_close,                                                            NULL)
        PHP_FE(mysqli_commit,                                                           NULL)
        PHP_FE(mysqli_connect,                                                          NULL)
@@ -76,8 +72,8 @@ function_entry mysqli_functions[] = {
        PHP_FE(mysqli_enable_rpl_parse,                                         NULL)
        PHP_FE(mysqli_errno,                                                            NULL)
        PHP_FE(mysqli_error,                                                            NULL)
-       PHP_FE(mysqli_execute,                                                          NULL)
-       PHP_FE(mysqli_fetch,                                                            NULL)
+       PHP_FE(mysqli_stmt_execute,                                                     NULL)
+       PHP_FALIAS(mysqli_execute, mysqli_stmt_execute,         NULL)
        PHP_FE(mysqli_fetch_field,                                                      NULL)
        PHP_FE(mysqli_fetch_fields,                                                     NULL)
        PHP_FE(mysqli_fetch_field_direct,                                       NULL)
@@ -93,7 +89,6 @@ function_entry mysqli_functions[] = {
        PHP_FE(mysqli_get_client_info,                                          NULL)
        PHP_FE(mysqli_get_client_version,                                       NULL)
        PHP_FE(mysqli_get_host_info,                                            NULL)
-       PHP_FE(mysqli_get_metadata,                                                     NULL)
        PHP_FE(mysqli_get_proto_info,                                           NULL)
        PHP_FE(mysqli_get_server_info,                                          NULL)
        PHP_FE(mysqli_get_server_version,                                       NULL)
@@ -108,28 +103,33 @@ function_entry mysqli_functions[] = {
        PHP_FE(mysqli_num_fields,                                                       NULL)
        PHP_FE(mysqli_num_rows,                                                         NULL)
        PHP_FE(mysqli_options,                                                          NULL)
-       PHP_FE(mysqli_param_count,                                                      NULL)
        PHP_FE(mysqli_ping,                                                                     NULL)
        PHP_FE(mysqli_prepare,                                                          NULL)
        PHP_FE(mysqli_report,                                                           NULL)
        PHP_FE(mysqli_query,                                                            NULL)
        PHP_FE(mysqli_real_connect,                                                     NULL)
        PHP_FE(mysqli_real_escape_string,                                       NULL)
-       PHP_FALIAS(mysqli_escape_string, 
-                               mysqli_real_escape_string,                              NULL)
        PHP_FE(mysqli_real_query,                                                       NULL)
        PHP_FE(mysqli_rollback,                                                         NULL)
        PHP_FE(mysqli_rpl_parse_enabled,                                        NULL)
        PHP_FE(mysqli_rpl_probe,                                                        NULL)
        PHP_FE(mysqli_rpl_query_type,                                           NULL)
        PHP_FE(mysqli_select_db,                                                        NULL)
-       PHP_FE(mysqli_send_long_data,                                           NULL)
+#ifndef HAVE_MYSQLI_OLDAPI
+       PHP_FE(mysqli_stmt_init,                                                        NULL)
+       PHP_FE(mysqli_stmt_prepare,                                                     NULL)
+#endif
+       PHP_FE(mysqli_stmt_result_metadata,                                     NULL)
+       PHP_FE(mysqli_stmt_send_long_data,                                      NULL)
+       PHP_FE(mysqli_stmt_bind_param,                                          third_arg_force_by_ref_rest)
+       PHP_FE(mysqli_stmt_bind_result,                                         second_arg_force_by_ref_rest)
+       PHP_FE(mysqli_stmt_fetch,                                                       NULL)
+       PHP_FE(mysqli_stmt_param_count,                                         NULL)
        PHP_FE(mysqli_send_query,                                                       NULL)
 #ifdef HAVE_EMBEDDED_MYSQLI
        PHP_FE(mysqli_server_end,                                                       NULL)
        PHP_FE(mysqli_server_init,                                                      NULL)
 #endif
-       PHP_FALIAS(mysqli_set_opt,              mysqli_options,         NULL)
        PHP_FE(mysqli_slave_query,                                                      NULL)
 #if MYSQL_VERSION_ID >= 40101
        PHP_FE(mysqli_sqlstate,                                                         NULL)
@@ -151,6 +151,25 @@ function_entry mysqli_functions[] = {
        PHP_FE(mysqli_thread_safe,                                                      NULL)
        PHP_FE(mysqli_use_result,                                                       NULL)
        PHP_FE(mysqli_warning_count,                                            NULL)
+
+       /* Aliases */
+       PHP_FALIAS(mysqli_bind_param,
+                               mysqli_stmt_bind_param,                                 third_arg_force_by_ref_rest)
+       PHP_FALIAS(mysqli_bind_result,
+                               mysqli_stmt_bind_result,                                second_arg_force_by_ref_rest)
+       PHP_FALIAS(mysqli_client_encoding, 
+                          mysqli_character_set_name,                           NULL)
+       PHP_FALIAS(mysqli_escape_string, 
+                               mysqli_real_escape_string,                              NULL)
+       PHP_FALIAS(mysqli_fetch, mysqli_stmt_fetch,                     NULL)
+       PHP_FALIAS(mysqli_param_count,
+                               mysqli_stmt_param_count,                                NULL)
+       PHP_FALIAS(mysqli_get_metadata,
+                               mysqli_stmt_result_metadata,                    NULL)
+       PHP_FALIAS(mysqli_send_long_data,
+                               mysqli_stmt_send_long_data,                             NULL)
+       PHP_FALIAS(mysqli_set_opt,              mysqli_options,         NULL)
+
        {NULL, NULL, NULL}      /* Must be the last line in mysqli_functions[] */
 };
 /* }}} */
@@ -199,6 +218,9 @@ function_entry mysqli_link_methods[] = {
        PHP_FALIAS(slave_query,mysqli_slave_query,NULL)
        PHP_FALIAS(ssl_set,mysqli_ssl_set,NULL)
        PHP_FALIAS(stat,mysqli_stat,NULL)
+#ifndef HAVE_MYSQLI_OLDAPI
+       PHP_FALIAS(stmt_init,mysqli_stmt_init, NULL)
+#endif
        PHP_FALIAS(store_result,mysqli_store_result,NULL)
        PHP_FALIAS(thread_safe,mysqli_thread_safe,NULL)
        PHP_FALIAS(use_result,mysqli_use_result,NULL)
@@ -234,16 +256,19 @@ function_entry mysqli_result_methods[] = {
  */
 function_entry mysqli_stmt_methods[] = {
        PHP_FALIAS(affected_rows,mysqli_stmt_affected_rows,NULL)
-       PHP_FALIAS(bind_param,mysqli_bind_param,second_arg_force_by_ref_rest)
-       PHP_FALIAS(bind_result,mysqli_bind_result,all_args_force_by_ref)
+       PHP_FALIAS(bind_param,mysqli_stmt_bind_param,second_arg_force_by_ref_rest)
+       PHP_FALIAS(bind_result,mysqli_stmt_bind_result,all_args_force_by_ref)
        PHP_FALIAS(close,mysqli_stmt_close,NULL)
        PHP_FALIAS(data_seek,mysqli_stmt_data_seek,NULL)
-       PHP_FALIAS(execute,mysqli_execute,NULL)
-       PHP_FALIAS(fetch,mysqli_fetch,NULL)
-       PHP_FALIAS(get_metadata, mysqli_get_metadata,NULL)
+       PHP_FALIAS(execute,mysqli_stmt_execute,NULL)
+       PHP_FALIAS(fetch,mysqli_stmt_fetch,NULL)
+       PHP_FALIAS(get_metadata, mysqli_stmt_result_metadata,NULL)
        PHP_FALIAS(num_rows, mysqli_stmt_num_rows,NULL)
-       PHP_FALIAS(send_long_data,mysqli_send_long_data,NULL)
+       PHP_FALIAS(send_long_data,mysqli_stmt_send_long_data,NULL)
        PHP_FALIAS(stmt,mysqli_prepare,NULL)
+#ifndef HAVE_MYSQLI_OLDAPI
+       PHP_FALIAS(prepare,mysqli_stmt_prepare, NULL)
+#endif
        PHP_FALIAS(store_result,mysqli_stmt_store_result,NULL)
        {NULL, NULL, NULL}
 };
index 397703647ae55505bf5e63a766794283cbc9de02..7d1032ec5127fb9febbb28a1612a9643ed79c9d6 100644 (file)
 #ifndef PHP_MYSQLI_H
 #define PHP_MYSQLI_H
 
-
 typedef struct {
        ulong           buflen;
-       char            *buffer;
+       char            *val;
        ulong           type;
 } VAR_BUFFER;
 
@@ -259,8 +258,6 @@ PHP_MINFO_FUNCTION(mysqli);
 PHP_FUNCTION(mysqli);
 PHP_FUNCTION(mysqli_affected_rows);
 PHP_FUNCTION(mysqli_autocommit);
-PHP_FUNCTION(mysqli_bind_param);
-PHP_FUNCTION(mysqli_bind_result);
 PHP_FUNCTION(mysqli_change_user);
 PHP_FUNCTION(mysqli_character_set_name);
 PHP_FUNCTION(mysqli_close);
@@ -280,8 +277,6 @@ PHP_FUNCTION(mysqli_enable_reads_from_master);
 PHP_FUNCTION(mysqli_enable_rpl_parse);
 PHP_FUNCTION(mysqli_errno);
 PHP_FUNCTION(mysqli_error);
-PHP_FUNCTION(mysqli_execute);
-PHP_FUNCTION(mysqli_fetch);
 PHP_FUNCTION(mysqli_fetch_array);
 PHP_FUNCTION(mysqli_fetch_assoc);
 PHP_FUNCTION(mysqli_fetch_object);
@@ -311,11 +306,10 @@ PHP_FUNCTION(mysqli_next_result);
 PHP_FUNCTION(mysqli_num_fields);
 PHP_FUNCTION(mysqli_num_rows);
 PHP_FUNCTION(mysqli_options);
-PHP_FUNCTION(mysqli_param_count);
 PHP_FUNCTION(mysqli_ping);
 PHP_FUNCTION(mysqli_prepare);
 PHP_FUNCTION(mysqli_query);
-PHP_FUNCTION(mysqli_get_metadata);
+PHP_FUNCTION(mysqli_stmt_result_metadata);
 PHP_FUNCTION(mysqli_report);
 PHP_FUNCTION(mysqli_read_query_result);
 PHP_FUNCTION(mysqli_real_connect);
@@ -327,7 +321,16 @@ PHP_FUNCTION(mysqli_rpl_parse_enabled);
 PHP_FUNCTION(mysqli_rpl_probe);
 PHP_FUNCTION(mysqli_rpl_query_type);
 PHP_FUNCTION(mysqli_select_db);
-PHP_FUNCTION(mysqli_send_long_data);
+PHP_FUNCTION(mysqli_stmt_bind_param);
+PHP_FUNCTION(mysqli_stmt_bind_result);
+PHP_FUNCTION(mysqli_stmt_execute);
+#ifndef MYSQLI_HAVE_OLDAPI
+PHP_FUNCTION(mysqli_stmt_init);
+PHP_FUNCTION(mysqli_stmt_prepare);
+#endif
+PHP_FUNCTION(mysqli_stmt_fetch);
+PHP_FUNCTION(mysqli_stmt_param_count);
+PHP_FUNCTION(mysqli_stmt_send_long_data);
 PHP_FUNCTION(mysqli_send_query);
 #ifdef HAVE_EMBEDDED_MYSQLI
 PHP_FUNCTION(mysqli_server_init);