diff options
author | SVN Migration <svn@php.net> | 2006-10-15 21:09:28 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2006-10-15 21:09:28 +0000 |
commit | 88ec761548b66f58acc1a86cdd0fc164ca925476 (patch) | |
tree | d0af978fa00d83bb1d82c613f66477fbd6bb18aa /ext/mysqli | |
parent | 268984b4787e797db6054313fc9ba3b9e845306e (diff) | |
download | php-git-PECL_OPENSSL.tar.gz |
This commit was manufactured by cvs2svn to create branch 'PECL_OPENSSL'.PECL_OPENSSL
Diffstat (limited to 'ext/mysqli')
114 files changed, 0 insertions, 9923 deletions
diff --git a/ext/mysqli/CREDITS b/ext/mysqli/CREDITS deleted file mode 100644 index 68cfa8a4ae..0000000000 --- a/ext/mysqli/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -MySQLi -Zak Greant, Georg Richter diff --git a/ext/mysqli/TODO b/ext/mysqli/TODO deleted file mode 100644 index c241b9b704..0000000000 --- a/ext/mysqli/TODO +++ /dev/null @@ -1,2 +0,0 @@ -- documentation -- ini-settings diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4 deleted file mode 100644 index 2c1af87054..0000000000 --- a/ext/mysqli/config.m4 +++ /dev/null @@ -1,64 +0,0 @@ -dnl -dnl $Id$ -dnl config.m4 for extension mysqli - -PHP_ARG_WITH(mysqli, for MySQLi support, -[ --with-mysqli[=FILE] Include MySQLi support. FILE is the optional pathname - to mysql_config]) - -PHP_ARG_ENABLE(embedded_mysqli, whether to enable embedded MySQLi support, -[ --enable-embedded-mysqli MYSQLi: Enable embedded support], no, no) - -if test "$PHP_MYSQLI" != "no"; then - -dnl there are no mysql libs currently bundled with PHP.. --Jani -dnl if test "$PHP_MYSQL" = "yes"; then -dnl AC_MSG_ERROR([--with-mysql (using bundled libs) can not be used together with --with-mysqli.]) -dnl fi - - if test "$PHP_MYSQLI" = "yes"; then - MYSQL_CONFIG=`$php_shtool path mysql_config` - else - MYSQL_CONFIG=$PHP_MYSQLI - fi - - MYSQL_LIB_NAME='mysqlclient' - if test "$PHP_EMBEDDED_MYSQLI" = "yes"; then - AC_DEFINE(HAVE_EMBEDDED_MYSQLI, 1, [embedded MySQL support enabled]) - MYSQL_LIB_CFG='--libmysqld-libs' - elif test "$enable_maintainer_zts" = "yes"; then - MYSQL_LIB_CFG='--libs_r' - MYSQL_LIB_NAME='mysqlclient_r' - else - MYSQL_LIB_CFG='--libs' - fi - - if test -x "$MYSQL_CONFIG" && $MYSQL_CONFIG $MYSQL_LIB_CFG > /dev/null 2>&1; then - MYSQLI_INCLINE=`$MYSQL_CONFIG --cflags | $SED -e "s/'//g"` - MYSQLI_LIBLINE=`$MYSQL_CONFIG $MYSQL_LIB_CFG | $SED -e "s/'//g"` - else - AC_MSG_RESULT([mysql_config not found]) - AC_MSG_ERROR([Please reinstall the mysql distribution]) - fi - - dnl - dnl Check the library - dnl - PHP_CHECK_LIBRARY($MYSQL_LIB_NAME, 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($MYSQL_LIB_NAME, mysql_stmt_field_count, - [ ],[ - AC_MSG_ERROR([MySQLI doesn't support versions < 4.1.3 (for MySQL 4.1.x) and < 5.0.1 for (MySQL 5.0.x) anymore. Please update your libraries.]) - ],[$MYSQLI_LIBLINE]) - ],[ - AC_MSG_ERROR([wrong mysql library version or lib not found. Check config.log for more information.]) - ],[ - $MYSQLI_LIBLINE - ]) - - PHP_NEW_EXTENSION(mysqli, mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c mysqli_fe.c mysqli_report.c mysqli_repl.c mysqli_driver.c mysqli_warning.c mysqli_exception.c mysqli_embedded.c, $ext_shared) - PHP_SUBST(MYSQLI_SHARED_LIBADD) -fi diff --git a/ext/mysqli/config.w32 b/ext/mysqli/config.w32 deleted file mode 100644 index 789112ea14..0000000000 --- a/ext/mysqli/config.w32 +++ /dev/null @@ -1,14 +0,0 @@ -// $Id$ -// vim:ft=javascript - -ARG_WITH("mysqli", "MySQLi support", "no"); - -if (PHP_MYSQLI != "no") { - if (CHECK_LIB("libmysql.lib", "mysqli", PHP_MYSQLI) && - CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_MYSQLI", PHP_MYSQLI + "\\include;" + PHP_PHP_BUILD + "\\include\\mysql;" + PHP_MYSQLI)) { - EXTENSION("mysqli", "mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c mysqli_fe.c mysqli_report.c mysqli_repl.c mysqli_driver.c mysqli_warning.c mysqli_exception.c mysqli_embedded.c"); - AC_DEFINE('HAVE_MYSQLILIB', 1, 'Have MySQLi library'); - } else { - WARNING("mysqli not enabled; libraries and headers not found"); - } -} diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c deleted file mode 100644 index 68368962a9..0000000000 --- a/ext/mysqli/mysqli.c +++ /dev/null @@ -1,1172 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "ext/standard/php_string.h" -#include "php_mysqli.h" -#include "zend_exceptions.h" - -#define MYSQLI_STORE_RESULT 0 -#define MYSQLI_USE_RESULT 1 - -ZEND_DECLARE_MODULE_GLOBALS(mysqli) -static PHP_GINIT_FUNCTION(mysqli); - -static zend_object_handlers mysqli_object_handlers; -static HashTable classes; -static HashTable mysqli_driver_properties; -static HashTable mysqli_link_properties; -static HashTable mysqli_result_properties; -static HashTable mysqli_stmt_properties; -static HashTable mysqli_warning_properties; - -zend_class_entry *mysqli_link_class_entry; -zend_class_entry *mysqli_stmt_class_entry; -zend_class_entry *mysqli_result_class_entry; -zend_class_entry *mysqli_driver_class_entry; -zend_class_entry *mysqli_warning_class_entry; -zend_class_entry *mysqli_exception_class_entry; - -extern void php_mysqli_connect(INTERNAL_FUNCTION_PARAMETERS); - -typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC); -typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval TSRMLS_DC); - -typedef struct _mysqli_prop_handler { - mysqli_read_t read_func; - mysqli_write_t write_func; -} mysqli_prop_handler; - -/* {{{ php_free_stmt_bind_buffer */ -void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type) -{ - unsigned int i; - - if (!bbuf.var_cnt) { - return; - } - - for (i=0; i < bbuf.var_cnt; i++) { - - /* free temporary bind buffer */ - if (type == FETCH_RESULT && bbuf.buf[i].val) { - efree(bbuf.buf[i].val); - } - - if (bbuf.vars[i]) { - zval_ptr_dtor(&bbuf.vars[i]); - } - } - - if (bbuf.vars) { - efree(bbuf.vars); - } - - /* - Don't free bbuf.is_null for FETCH_RESULT since we have allocated - is_null and buf in one block so we free only buf, which is the beginning - of the block. When FETCH_SIMPLE then buf wasn't allocated together with - buf and we have to free it. - */ - if (type == FETCH_RESULT) { - efree(bbuf.buf); - } else if (type == FETCH_SIMPLE){ - efree(bbuf.is_null); - } - - bbuf.var_cnt = 0; - return; -} -/* }}} */ - -/* {{{ php_clear_stmt_bind */ -void php_clear_stmt_bind(MY_STMT *stmt) -{ - if (stmt->stmt) { - mysql_stmt_close(stmt->stmt); - } - - php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); - php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); - - if (stmt->query) { - efree(stmt->query); - } - efree(stmt); - return; -} -/* }}} */ - -/* {{{ php_clear_mysql */ -void php_clear_mysql(MY_MYSQL *mysql) { - if (mysql->li_read) { - efree(Z_STRVAL_P(mysql->li_read)); - FREE_ZVAL(mysql->li_read); - mysql->li_read = NULL; - } -} -/* }}} */ - -/* {{{ mysqli_objects_free_storage - */ -static void mysqli_objects_free_storage(void *object TSRMLS_DC) -{ - zend_object *zo = (zend_object *)object; - mysqli_object *intern = (mysqli_object *)zo; - MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr; - - my_efree(my_res); - zend_object_std_dtor(&intern->zo TSRMLS_CC); - efree(intern); -} -/* }}} */ - -/* {{{ mysqli_link_free_storage - */ -static void mysqli_link_free_storage(void *object TSRMLS_DC) -{ - zend_object *zo = (zend_object *)object; - mysqli_object *intern = (mysqli_object *)zo; - MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr; - - if (my_res && my_res->ptr) { - MY_MYSQL *mysql = (MY_MYSQL *)my_res->ptr; - if (mysql->mysql) { - mysql_close(mysql->mysql); - } - php_clear_mysql(mysql); - efree(mysql); - } - mysqli_objects_free_storage(object TSRMLS_CC); -} -/* }}} */ - -/* {{{ mysqli_stmt_free_storage - */ -static void mysqli_stmt_free_storage(void *object TSRMLS_DC) -{ - zend_object *zo = (zend_object *)object; - mysqli_object *intern = (mysqli_object *)zo; - MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr; - - if (my_res && my_res->ptr) { - MY_STMT *stmt = (MY_STMT *)my_res->ptr; - php_clear_stmt_bind(stmt); - } - mysqli_objects_free_storage(object TSRMLS_CC); -} -/* }}} */ - -/* {{{ mysqli_result_free_storage - */ -static void mysqli_result_free_storage(void *object TSRMLS_DC) -{ - zend_object *zo = (zend_object *)object; - mysqli_object *intern = (mysqli_object *)zo; - MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr; - - if (my_res && my_res->ptr) { - mysql_free_result(my_res->ptr); - } - mysqli_objects_free_storage(object TSRMLS_CC); -} -/* }}} */ - -/* {{{ mysqli_warning_free_storage - */ -static void mysqli_warning_free_storage(void *object TSRMLS_DC) -{ - zend_object *zo = (zend_object *)object; - mysqli_object *intern = (mysqli_object *)zo; - MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr; - - if (my_res && my_res->ptr) { - php_clear_warnings((MYSQLI_WARNING *)my_res->info); - my_res->ptr = NULL; - } - mysqli_objects_free_storage(object TSRMLS_CC); -} -/* }}} */ - -/* {{{ mysqli_read_na */ -static int mysqli_read_na(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - *retval = NULL; - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot read property"); - return FAILURE; -} -/* }}} */ - -/* {{{ mysqli_write_na */ -static int mysqli_write_na(mysqli_object *obj, zval *newval TSRMLS_DC) -{ - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot write property"); - return FAILURE; -} -/* }}} */ - -/* {{{ mysqli_read_property */ -zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC) -{ - zval tmp_member; - zval *retval; - mysqli_object *obj; - mysqli_prop_handler *hnd; - zend_object_handlers *std_hnd; - int ret; - - ret = FAILURE; - obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC); - - if (member->type != IS_STRING) { - tmp_member = *member; - zval_copy_ctor(&tmp_member); - convert_to_string(&tmp_member); - member = &tmp_member; - } - - if (obj->prop_handler != NULL) { - ret = zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd); - } - - if (ret == SUCCESS) { - if (strcmp(obj->zo.ce->name, "mysqli_driver") && - (!obj->ptr || ((MYSQLI_RESOURCE *)(obj->ptr))->status < MYSQLI_STATUS_INITIALIZED)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name ); - retval = EG(uninitialized_zval_ptr); - return(retval); - } - - ret = hnd->read_func(obj, &retval TSRMLS_CC); - if (ret == SUCCESS) { - /* ensure we're creating a temporary variable */ - retval->refcount = 0; - } else { - retval = EG(uninitialized_zval_ptr); - } - } else { - std_hnd = zend_get_std_object_handlers(); - retval = std_hnd->read_property(object, member, type TSRMLS_CC); - } - - if (member == &tmp_member) { - zval_dtor(member); - } - return(retval); -} -/* }}} */ - -/* {{{ mysqli_write_property */ -void mysqli_write_property(zval *object, zval *member, zval *value TSRMLS_DC) -{ - zval tmp_member; - mysqli_object *obj; - mysqli_prop_handler *hnd; - zend_object_handlers *std_hnd; - int ret; - - if (member->type != IS_STRING) { - tmp_member = *member; - zval_copy_ctor(&tmp_member); - convert_to_string(&tmp_member); - member = &tmp_member; - } - - ret = FAILURE; - obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC); - - if (obj->prop_handler != NULL) { - ret = zend_hash_find((HashTable *)obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd); - } - if (ret == SUCCESS) { - hnd->write_func(obj, value TSRMLS_CC); - if (! PZVAL_IS_REF(value) && value->refcount == 0) { - value->refcount++; - zval_ptr_dtor(&value); - } - } else { - std_hnd = zend_get_std_object_handlers(); - std_hnd->write_property(object, member, value TSRMLS_CC); - } - - if (member == &tmp_member) { - zval_dtor(member); - } -} -/* }}} */ - -/* {{{ void mysqli_add_property(HashTable *h, char *pname, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) */ -void mysqli_add_property(HashTable *h, char *pname, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) { - mysqli_prop_handler p; - - p.read_func = (r_func) ? r_func : mysqli_read_na; - p.write_func = (w_func) ? w_func : mysqli_write_na; - - zend_hash_add(h, pname, strlen(pname) + 1, &p, sizeof(mysqli_prop_handler), NULL); -} -/* }}} */ - -static union _zend_function *php_mysqli_constructor_get(zval *object TSRMLS_DC) -{ - mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC); - zend_class_entry * ce = Z_OBJCE_P(object); - - if (ce != mysqli_link_class_entry && ce != mysqli_stmt_class_entry && - ce != mysqli_result_class_entry && ce != mysqli_driver_class_entry && - ce != mysqli_warning_class_entry) { - return zend_std_get_constructor(object TSRMLS_CC); - } else { - static zend_internal_function f; - - f.function_name = obj->zo.ce->name; - f.scope = obj->zo.ce; - f.arg_info = NULL; - f.num_args = 0; - f.fn_flags = 0; - - f.type = ZEND_INTERNAL_FUNCTION; - if (obj->zo.ce == mysqli_link_class_entry) { - f.handler = ZEND_FN(mysqli_connect); - } else if (obj->zo.ce == mysqli_stmt_class_entry) { - f.handler = ZEND_FN(mysqli_stmt_construct); - } else if (obj->zo.ce == mysqli_result_class_entry) { - f.handler = ZEND_FN(mysqli_result_construct); - } else if (obj->zo.ce == mysqli_driver_class_entry) { - f.handler = ZEND_FN(mysqli_driver_construct); - } else if (obj->zo.ce == mysqli_warning_class_entry) { - f.handler = ZEND_MN(mysqli_warning___construct); - } - - return (union _zend_function*)&f; - } -} - -/* {{{ mysqli_objects_new - */ -PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - mysqli_object *intern; - zval *tmp; - zend_class_entry *mysqli_base_class; - zend_objects_free_object_storage_t free_storage; - - intern = emalloc(sizeof(mysqli_object)); - memset(intern, 0, sizeof(mysqli_object)); - intern->ptr = NULL; - intern->prop_handler = NULL; - - mysqli_base_class = class_type; - while (mysqli_base_class->type != ZEND_INTERNAL_CLASS && mysqli_base_class->parent != NULL) - { - mysqli_base_class = mysqli_base_class->parent; - } - zend_hash_find(&classes, mysqli_base_class->name, mysqli_base_class->name_length + 1, - (void **) &intern->prop_handler); - - zend_object_std_init(&intern->zo, class_type TSRMLS_CC); - zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, - (void *) &tmp, sizeof(zval *)); - - /* link object */ - if (instanceof_function(class_type, mysqli_link_class_entry TSRMLS_CC)) { - free_storage = mysqli_link_free_storage; - } else if (instanceof_function(class_type, mysqli_stmt_class_entry TSRMLS_CC)) { /* stmt object */ - free_storage = mysqli_stmt_free_storage; - } else if (instanceof_function(class_type, mysqli_result_class_entry TSRMLS_CC)) { /* result object */ - free_storage = mysqli_result_free_storage; - } else if (instanceof_function(class_type, mysqli_warning_class_entry TSRMLS_CC)) { /* warning object */ - free_storage = mysqli_warning_free_storage; - } else { - free_storage = mysqli_objects_free_storage; - } - - retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, free_storage, NULL TSRMLS_CC); - retval.handlers = &mysqli_object_handlers; - - return retval; -} -/* }}} */ - -/* {{{ mysqli_module_entry - */ -zend_module_entry mysqli_module_entry = { - STANDARD_MODULE_HEADER, - "mysqli", - mysqli_functions, - PHP_MINIT(mysqli), - PHP_MSHUTDOWN(mysqli), - PHP_RINIT(mysqli), - PHP_RSHUTDOWN(mysqli), - PHP_MINFO(mysqli), - "0.1", /* Replace with version number for your extension */ - PHP_MODULE_GLOBALS(mysqli), - PHP_GINIT(mysqli), - NULL, - NULL, - STANDARD_MODULE_PROPERTIES_EX -}; -/* }}} */ - -#ifdef COMPILE_DL_MYSQLI -ZEND_GET_MODULE(mysqli) -#endif - -/* {{{ PHP_INI_BEGIN -*/ -PHP_INI_BEGIN() - STD_PHP_INI_ENTRY_EX("mysqli.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mysqli_globals, mysqli_globals, display_link_numbers) - STD_PHP_INI_ENTRY("mysqli.default_host", NULL, PHP_INI_ALL, OnUpdateString, default_host, zend_mysqli_globals, mysqli_globals) - STD_PHP_INI_ENTRY("mysqli.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysqli_globals, mysqli_globals) - STD_PHP_INI_ENTRY("mysqli.default_pw", NULL, PHP_INI_ALL, OnUpdateString, default_pw, zend_mysqli_globals, mysqli_globals) - STD_PHP_INI_ENTRY("mysqli.default_port", "3306", PHP_INI_ALL, OnUpdateLong, default_port, zend_mysqli_globals, mysqli_globals) - STD_PHP_INI_ENTRY("mysqli.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals) - STD_PHP_INI_BOOLEAN("mysqli.reconnect", "0", PHP_INI_SYSTEM, OnUpdateLong, reconnect, zend_mysqli_globals, mysqli_globals) -PHP_INI_END() - -/* }}} */ - -/* {{{ PHP_GINIT_FUNCTION - */ -static PHP_GINIT_FUNCTION(mysqli) -{ - mysqli_globals->num_links = 0; - mysqli_globals->max_links = 0; - mysqli_globals->default_port = 0; - mysqli_globals->default_host = NULL; - mysqli_globals->default_user = NULL; - mysqli_globals->default_pw = NULL; - mysqli_globals->default_socket = NULL; - mysqli_globals->reconnect = 0; - mysqli_globals->report_mode = 0; - mysqli_globals->report_ht = 0; -#ifdef HAVE_EMBEDDED_MYSQLI - mysqli_globals->embedded = 1; -#else - mysqli_globals->embedded = 0; -#endif -} -/* }}} */ - -/* {{{ PHP_MINIT_FUNCTION - */ -PHP_MINIT_FUNCTION(mysqli) -{ - zend_class_entry *ce,cex; - zend_object_handlers *std_hnd = zend_get_std_object_handlers(); - - REGISTER_INI_ENTRIES(); - - memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - mysqli_object_handlers.clone_obj = NULL; - mysqli_object_handlers.read_property = mysqli_read_property; - mysqli_object_handlers.write_property = mysqli_write_property; - mysqli_object_handlers.get_property_ptr_ptr = std_hnd->get_property_ptr_ptr; - mysqli_object_handlers.get_constructor = php_mysqli_constructor_get; - - zend_hash_init(&classes, 0, NULL, NULL, 1); - - INIT_CLASS_ENTRY(cex, "mysqli_sql_exception", mysqli_exception_methods); -#ifdef HAVE_SPL - mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException, NULL TSRMLS_CC); -#else - mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC); -#endif - mysqli_exception_class_entry->ce_flags |= ZEND_ACC_FINAL; - zend_declare_property_long(mysqli_exception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_string(mysqli_exception_class_entry, "sqlstate", sizeof("sqlstate")-1, "00000", ZEND_ACC_PROTECTED TSRMLS_CC); - - REGISTER_MYSQLI_CLASS_ENTRY("mysqli_driver", mysqli_driver_class_entry, mysqli_driver_methods); - ce = mysqli_driver_class_entry; - zend_hash_init(&mysqli_driver_properties, 0, NULL, NULL, 1); - MYSQLI_ADD_PROPERTIES(&mysqli_driver_properties, mysqli_driver_property_entries); - zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_driver_properties, sizeof(mysqli_driver_properties), NULL); - ce->ce_flags |= ZEND_ACC_FINAL_CLASS; - - REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods); - ce = mysqli_link_class_entry; - zend_hash_init(&mysqli_link_properties, 0, NULL, NULL, 1); - MYSQLI_ADD_PROPERTIES(&mysqli_link_properties, mysqli_link_property_entries); - zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_link_properties, sizeof(mysqli_link_properties), NULL); - - REGISTER_MYSQLI_CLASS_ENTRY("mysqli_warning", mysqli_warning_class_entry, mysqli_warning_methods); - ce = mysqli_warning_class_entry; - ce->ce_flags |= ZEND_ACC_FINAL_CLASS | ZEND_ACC_PROTECTED; - zend_hash_init(&mysqli_warning_properties, 0, NULL, NULL, 1); - MYSQLI_ADD_PROPERTIES(&mysqli_warning_properties, mysqli_warning_property_entries); - zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_warning_properties, sizeof(mysqli_warning_properties), NULL); - - REGISTER_MYSQLI_CLASS_ENTRY("mysqli_result", mysqli_result_class_entry, mysqli_result_methods); - ce = mysqli_result_class_entry; - zend_hash_init(&mysqli_result_properties, 0, NULL, NULL, 1); - MYSQLI_ADD_PROPERTIES(&mysqli_result_properties, mysqli_result_property_entries); - zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_result_properties, sizeof(mysqli_result_properties), NULL); - - REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods); - ce = mysqli_stmt_class_entry; - zend_hash_init(&mysqli_stmt_properties, 0, NULL, NULL, 1); - MYSQLI_ADD_PROPERTIES(&mysqli_stmt_properties, mysqli_stmt_property_entries); - zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_stmt_properties, sizeof(mysqli_stmt_properties), NULL); - - /* mysqli_options */ - REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_GROUP", MYSQL_READ_DEFAULT_GROUP, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_FILE", MYSQL_READ_DEFAULT_FILE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_OPT_CONNECT_TIMEOUT", MYSQL_OPT_CONNECT_TIMEOUT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_OPT_LOCAL_INFILE", MYSQL_OPT_LOCAL_INFILE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_INIT_COMMAND", MYSQL_INIT_COMMAND, CONST_CS | CONST_PERSISTENT); - - /* mysqli_real_connect flags */ - REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_SSL", CLIENT_SSL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_COMPRESS",CLIENT_COMPRESS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_NO_SCHEMA", CLIENT_NO_SCHEMA, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_FOUND_ROWS", CLIENT_FOUND_ROWS, CONST_CS | CONST_PERSISTENT); - - /* for mysqli_query */ - REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", 0, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_USE_RESULT", 1, CONST_CS | CONST_PERSISTENT); - - /* for mysqli_fetch_assoc */ - REGISTER_LONG_CONSTANT("MYSQLI_ASSOC", MYSQLI_ASSOC, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_NUM", MYSQLI_NUM, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_BOTH", MYSQLI_BOTH, CONST_CS | CONST_PERSISTENT); - - /* for mysqli_stmt_set_attr */ - REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH", STMT_ATTR_UPDATE_MAX_LENGTH, CONST_CS | CONST_PERSISTENT); - -#if MYSQL_VERSION_ID > 50003 - REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_CURSOR_TYPE", STMT_ATTR_CURSOR_TYPE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_NO_CURSOR", CURSOR_TYPE_NO_CURSOR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_READ_ONLY", CURSOR_TYPE_READ_ONLY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_FOR_UPDATE", CURSOR_TYPE_FOR_UPDATE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_SCROLLABLE", CURSOR_TYPE_SCROLLABLE, CONST_CS | CONST_PERSISTENT); -#endif - -#if MYSQL_VERSION_ID > 50007 - REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_PREFETCH_ROWS", STMT_ATTR_PREFETCH_ROWS, CONST_CS | CONST_PERSISTENT); -#endif - - /* column information */ - REGISTER_LONG_CONSTANT("MYSQLI_NOT_NULL_FLAG", NOT_NULL_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_PRI_KEY_FLAG", PRI_KEY_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_UNIQUE_KEY_FLAG", UNIQUE_KEY_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_MULTIPLE_KEY_FLAG", MULTIPLE_KEY_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_BLOB_FLAG", BLOB_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_UNSIGNED_FLAG", UNSIGNED_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_ZEROFILL_FLAG", ZEROFILL_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_AUTO_INCREMENT_FLAG", AUTO_INCREMENT_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TIMESTAMP_FLAG", TIMESTAMP_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_SET_FLAG", SET_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_NUM_FLAG", NUM_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_PART_KEY_FLAG", PART_KEY_FLAG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_GROUP_FLAG", GROUP_FLAG, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DECIMAL", FIELD_TYPE_DECIMAL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TINY", FIELD_TYPE_TINY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_SHORT", FIELD_TYPE_SHORT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONG", FIELD_TYPE_LONG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_FLOAT", FIELD_TYPE_FLOAT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DOUBLE", FIELD_TYPE_DOUBLE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NULL", FIELD_TYPE_NULL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TIMESTAMP", FIELD_TYPE_TIMESTAMP, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONGLONG", FIELD_TYPE_LONGLONG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_INT24", FIELD_TYPE_INT24, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DATE", FIELD_TYPE_DATE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TIME", FIELD_TYPE_TIME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DATETIME", FIELD_TYPE_DATETIME , CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_YEAR", FIELD_TYPE_YEAR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NEWDATE", FIELD_TYPE_NEWDATE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_ENUM", FIELD_TYPE_ENUM, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_SET", FIELD_TYPE_SET, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TINY_BLOB", FIELD_TYPE_TINY_BLOB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_MEDIUM_BLOB", FIELD_TYPE_MEDIUM_BLOB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONG_BLOB", FIELD_TYPE_LONG_BLOB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BLOB", FIELD_TYPE_BLOB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_VAR_STRING", FIELD_TYPE_VAR_STRING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_STRING", FIELD_TYPE_STRING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_CHAR", FIELD_TYPE_CHAR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_INTERVAL", FIELD_TYPE_INTERVAL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_GEOMETRY", FIELD_TYPE_GEOMETRY, CONST_CS | CONST_PERSISTENT); - -#if MYSQL_VERSION_ID > 50002 - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NEWDECIMAL", FIELD_TYPE_NEWDECIMAL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BIT", FIELD_TYPE_BIT, CONST_CS | CONST_PERSISTENT); -#endif - - - - /* replication */ - REGISTER_LONG_CONSTANT("MYSQLI_RPL_MASTER", MYSQL_RPL_MASTER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_RPL_SLAVE", MYSQL_RPL_SLAVE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_RPL_ADMIN", MYSQL_RPL_ADMIN, CONST_CS | CONST_PERSISTENT); - - /* bind support */ - REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_CS | CONST_PERSISTENT); -#ifdef MYSQL_DATA_TRUNCATED - REGISTER_LONG_CONSTANT("MYSQLI_DATA_TRUNCATED", MYSQL_DATA_TRUNCATED, CONST_CS | CONST_PERSISTENT); -#endif - - /* reporting */ - REGISTER_LONG_CONSTANT("MYSQLI_REPORT_INDEX", MYSQLI_REPORT_INDEX, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ERROR", MYSQLI_REPORT_ERROR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_REPORT_STRICT", MYSQLI_REPORT_STRICT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_REPORT_ALL", MYSQLI_REPORT_ALL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("MYSQLI_REPORT_OFF", 0, CONST_CS | CONST_PERSISTENT); - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MSHUTDOWN_FUNCTION - */ -PHP_MSHUTDOWN_FUNCTION(mysqli) -{ - zend_hash_destroy(&mysqli_driver_properties); - zend_hash_destroy(&mysqli_result_properties); - zend_hash_destroy(&mysqli_stmt_properties); - zend_hash_destroy(&mysqli_warning_properties); - zend_hash_destroy(&mysqli_link_properties); - zend_hash_destroy(&classes); - - UNREGISTER_INI_ENTRIES(); - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RINIT_FUNCTION - */ -PHP_RINIT_FUNCTION(mysqli) -{ - MyG(error_msg) = NULL; - MyG(error_no) = 0; - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RSHUTDOWN_FUNCTION - */ -PHP_RSHUTDOWN_FUNCTION(mysqli) -{ - if (MyG(error_msg)) { - efree(MyG(error_msg)); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION - */ -PHP_MINFO_FUNCTION(mysqli) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "MysqlI Support", "enabled"); - php_info_print_table_row(2, "Client API library version", mysql_get_client_info()); - php_info_print_table_row(2, "Client API header version", MYSQL_SERVER_VERSION); - php_info_print_table_row(2, "MYSQLI_SOCKET", MYSQL_UNIX_ADDR); - - - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); -} -/* }}} */ - -/* {{{ mixed mysqli_stmt_construct() -constructor for statement object. -Parameters: - object -> mysqli_stmt_init - object, query -> mysqli_prepare -*/ -ZEND_FUNCTION(mysqli_stmt_construct) -{ - MY_MYSQL *mysql; - zval *mysql_link; - MY_STMT *stmt; - MYSQLI_RESOURCE *mysqli_resource; - char *statement; - int stmt_len; - - switch (ZEND_NUM_ARGS()) - { - case 1: /* mysql_stmt_init */ - if (zend_parse_parameters(1 TSRMLS_CC, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT)); - - stmt->stmt = mysql_stmt_init(mysql->mysql); - break; - case 2: - if (zend_parse_parameters(2 TSRMLS_CC, "Os", &mysql_link, mysqli_link_class_entry, &statement, &stmt_len)==FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT)); - - if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) { - mysql_stmt_prepare(stmt->stmt, statement, stmt_len); - } - break; - default: - WRONG_PARAM_COUNT; - break; - } - - if (!stmt->stmt) { - efree(stmt); - RETURN_FALSE; - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)stmt; - mysqli_resource->status = (ZEND_NUM_ARGS() == 1) ? MYSQLI_STATUS_INITIALIZED : MYSQLI_STATUS_VALID; - - ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource; -} -/* }}} */ - -/* {{{ mixed mysqli_result_construct() -constructor for result object. -Parameters: - object [, mode] -> mysqli_store/use_result -*/ -ZEND_FUNCTION(mysqli_result_construct) -{ - MY_MYSQL *mysql; - MYSQL_RES *result; - zval *mysql_link; - MYSQLI_RESOURCE *mysqli_resource; - long resmode = MYSQLI_STORE_RESULT; - - switch (ZEND_NUM_ARGS()) { - case 1: - if (zend_parse_parameters(1 TSRMLS_CC, "O", &mysql_link, mysqli_link_class_entry)==FAILURE) { - return; - } - break; - case 2: - if (zend_parse_parameters(2 TSRMLS_CC, "Ol", &mysql_link, mysqli_link_class_entry, &resmode)==FAILURE) { - return; - } - break; - default: - WRONG_PARAM_COUNT; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - result = (resmode == MYSQLI_STORE_RESULT) ? mysql_store_result(mysql->mysql) : - mysql_use_result(mysql->mysql); - - if (!result) { - RETURN_FALSE; - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)result; - mysqli_resource->status = MYSQLI_STATUS_VALID; - - ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource; - -} -/* }}} */ - -/* {{{ php_mysqli_fetch_into_hash - */ -void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags, int into_object) -{ - MYSQL_RES *result; - zval *mysql_result; - long fetchtype; - unsigned int i; - MYSQL_FIELD *fields; - MYSQL_ROW row; - unsigned long *field_len; - zval *ctor_params = NULL; - zend_class_entry *ce = NULL; - - if (into_object) { - char *class_name; - int class_name_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sz", &mysql_result, mysqli_result_class_entry, &class_name, &class_name_len, &ctor_params) == FAILURE) { - return; - } - if (ZEND_NUM_ARGS() < (getThis() ? 1 : 2)) { - ce = zend_standard_class_def; - } else { - ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC); - } - if (!ce) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not find class '%s'", class_name); - return; - } - fetchtype = MYSQLI_ASSOC; - } else { - if (override_flags) { - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - fetchtype = override_flags; - } else { - fetchtype = MYSQLI_BOTH; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) { - return; - } - } - } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if ((fetchtype & MYSQLI_BOTH) == 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH"); - RETURN_FALSE; - } - - if (!(row = mysql_fetch_row(result))) { - RETURN_NULL(); - } - - if (fetchtype & MYSQLI_ASSOC) { - fields = mysql_fetch_fields(result); - } - - array_init(return_value); - field_len = mysql_fetch_lengths(result); - - for (i = 0; i < mysql_num_fields(result); i++) { - if (row[i]) { - zval *res; - - MAKE_STD_ZVAL(res); - - /* check if we need magic quotes */ - if (PG(magic_quotes_runtime)) { - Z_TYPE_P(res) = IS_STRING; - Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC); - } else { - ZVAL_STRINGL(res, row[i], field_len[i], 1); - } - - if (fetchtype & MYSQLI_NUM) { - add_index_zval(return_value, i, res); - } - if (fetchtype & MYSQLI_ASSOC) { - if (fetchtype & MYSQLI_NUM) { - ZVAL_ADDREF(res); - } - add_assoc_zval(return_value, fields[i].name, res); - } - } else { - if (fetchtype & MYSQLI_NUM) { - add_index_null(return_value, i); - } - if (fetchtype & MYSQLI_ASSOC) { - add_assoc_null(return_value, fields[i].name); - } - } - } - - if (into_object) { - zval dataset = *return_value; - zend_fcall_info fci; - zend_fcall_info_cache fcc; - zval *retval_ptr; - - object_and_properties_init(return_value, ce, NULL); - zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC); - - if (ce->constructor) { - fci.size = sizeof(fci); - fci.function_table = &ce->function_table; - fci.function_name = NULL; - fci.symbol_table = NULL; - fci.object_pp = &return_value; - fci.retval_ptr_ptr = &retval_ptr; - if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) { - if (Z_TYPE_P(ctor_params) == IS_ARRAY) { - HashTable *ht = Z_ARRVAL_P(ctor_params); - Bucket *p; - - fci.param_count = 0; - fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0); - p = ht->pListHead; - while (p != NULL) { - fci.params[fci.param_count++] = (zval**)p->pData; - p = p->pListNext; - } - } else { - /* Two problems why we throw exceptions here: PHP is typeless - * and hence passing one argument that's not an array could be - * by mistake and the other way round is possible, too. The - * single value is an array. Also we'd have to make that one - * argument passed by reference. - */ - zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC); - return; - } - } else { - fci.param_count = 0; - fci.params = NULL; - } - fci.no_separation = 1; - - fcc.initialized = 1; - fcc.function_handler = ce->constructor; - fcc.calling_scope = EG(scope); - fcc.object_pp = &return_value; - - if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", ce->name, ce->constructor->common.function_name); - } else { - if (retval_ptr) { - zval_ptr_dtor(&retval_ptr); - } - } - if (fci.params) { - efree(fci.params); - } - } else if (ctor_params) { - zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Class %s does not have a constructor hence you cannot use ctor_params", ce->name); - } - } -} -/* }}} */ - -/* {{{ php_mysqli_set_error - */ -PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC) -{ - MyG(error_no) = mysql_errno; - if (MyG(error_msg)) { - efree(MyG(error_msg)); - } - MyG(error_msg) = estrdup(mysql_err); -} -/* }}} */ - -#define ALLOC_CALLBACK_ARGS(a, b, c)\ -if (c) {\ - a = (zval ***)safe_emalloc(c, sizeof(zval **), 0);\ - for (i = b; i < c; i++) {\ - a[i] = emalloc(sizeof(zval *));\ - MAKE_STD_ZVAL(*a[i]);\ - }\ -} - -#define FREE_CALLBACK_ARGS(a, b, c)\ -if (a) {\ - for (i=b; i < c; i++) {\ - zval_ptr_dtor(a[i]);\ - efree(a[i]);\ - }\ - efree(a);\ -} - -#define LOCAL_INFILE_ERROR_MSG(source,dest)\ -memset(source, 0, LOCAL_INFILE_ERROR_LEN);\ -memcpy(source, dest, LOCAL_INFILE_ERROR_LEN-1); - -/* {{{ void php_set_local_infile_handler_default -*/ -void php_set_local_infile_handler_default(MY_MYSQL *mysql) { - /* register internal callback functions */ - mysql_set_local_infile_handler(mysql->mysql, &php_local_infile_init, &php_local_infile_read, - &php_local_infile_end, &php_local_infile_error, (void *)mysql); - mysql->li_read = NULL; -} -/* }}} */ - -/* {{{ php_local_infile_init - */ -int php_local_infile_init(void **ptr, const char *filename, void *userdata) -{ - mysqli_local_infile *data; - MY_MYSQL *mysql; - php_stream_context *context = NULL; - - TSRMLS_FETCH(); - - /* save pointer to MY_MYSQL structure (userdata) */ - if (!(*ptr= data= ((mysqli_local_infile *)calloc(1, sizeof(mysqli_local_infile))))) { - return 1; - } - - if (!(mysql = (MY_MYSQL *)userdata)) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, ER(CR_UNKNOWN_ERROR)); - return 1; - } - - /* check open_basedir */ - if (PG(open_basedir)) { - if (php_check_open_basedir_ex(filename, 0 TSRMLS_CC) == -1) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, "open_basedir restriction in effect. Unable to open file"); - return 1; - } - } - - mysql->li_stream = php_stream_open_wrapper_ex((char *)filename, "r", 0, NULL, context); - - if (mysql->li_stream == NULL) { - sprintf((char *)data->error_msg, "Can't find file '%-.64s'.", filename); - return 1; - } - - data->userdata = mysql; - - return 0; -} -/* }}} */ - -/* {{{ int php_local_infile_read */ -int php_local_infile_read(void *ptr, char *buf, uint buf_len) -{ - mysqli_local_infile *data; - MY_MYSQL *mysql; - zval ***callback_args; - zval *retval; - zval *fp; - int argc = 4; - int i; - long rc; - - TSRMLS_FETCH(); - - data= (mysqli_local_infile *)ptr; - mysql = data->userdata; - - /* default processing */ - if (!mysql->li_read) { - int count; - - count = (int)php_stream_read(mysql->li_stream, buf, buf_len); - - if (count < 0) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, ER(2)); - } - - return count; - } - - ALLOC_CALLBACK_ARGS(callback_args, 1, argc); - - /* set parameters: filepointer, buffer, buffer_len, errormsg */ - - MAKE_STD_ZVAL(fp); - php_stream_to_zval(mysql->li_stream, fp); - callback_args[0] = &fp; - ZVAL_STRING(*callback_args[1], "", 1); - ZVAL_LONG(*callback_args[2], buf_len); - ZVAL_STRING(*callback_args[3], "", 1); - - if (call_user_function_ex(EG(function_table), - NULL, - mysql->li_read, - &retval, - argc, - callback_args, - 0, - NULL TSRMLS_CC) == SUCCESS) { - - rc = Z_LVAL_P(retval); - zval_ptr_dtor(&retval); - - if (rc > 0) { - if (rc > buf_len) { - /* check buffer overflow */ - LOCAL_INFILE_ERROR_MSG(data->error_msg, "Read buffer too large"); - rc = -1; - } else { - memcpy(buf, Z_STRVAL_P(*callback_args[1]), rc); - } - } - if (rc < 0) { - LOCAL_INFILE_ERROR_MSG(data->error_msg, Z_STRVAL_P(*callback_args[3])); - } - } else { - LOCAL_INFILE_ERROR_MSG(data->error_msg, "Can't execute load data local init callback function"); - rc = -1; - } - - FREE_CALLBACK_ARGS(callback_args, 1, argc); - efree(fp); - return rc; -} -/* }}} */ - -/* {{{ php_local_infile_error - */ -int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len) -{ - mysqli_local_infile *data = (mysqli_local_infile *) ptr; - - if (data) { - strcpy(error_msg, data->error_msg); - return 2000; - } - strcpy(error_msg, ER(CR_OUT_OF_MEMORY)); - return CR_OUT_OF_MEMORY; -} -/* }}} */ - -/* {{{ php_local_infile_end - */ -void php_local_infile_end(void *ptr) -{ - mysqli_local_infile *data; - MY_MYSQL *mysql; - - TSRMLS_FETCH(); - - data= (mysqli_local_infile *)ptr; - - if (!data || !(mysql = data->userdata)) { - if (data) { - free(data); - } - return; - } - - php_stream_close(mysql->li_stream); - free(data); - return; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli.dsp b/ext/mysqli/mysqli.dsp deleted file mode 100755 index a334202187..0000000000 --- a/ext/mysqli/mysqli.dsp +++ /dev/null @@ -1,120 +0,0 @@ -# Microsoft Developer Studio Project File - Name="mysqli" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=mysqli - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "mysqli.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "mysqli.mak" CFG="mysqli - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "mysqli - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "mysqli - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "mysqli - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQLI_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include" /I "..\..\..\php_build\include\mysqli" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_MYSQLI" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "PHP_MYSQLI_EXPORTS" /D "HAVE_ZLIB" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "NDEBUG"
-# ADD RSC /l 0x407 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php5ts.lib zlib.lib libmySQL.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_mysqli.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\release"
-
-!ELSEIF "$(CFG)" == "mysqli - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MYSQLI_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include" /I "..\..\..\php_build\include\mysqli" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_MYSQLI" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "PHP_MYSQLI_EXPORTS" /D "HAVE_ZLIB" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "_DEBUG"
-# ADD RSC /l 0x407 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 php5ts_debug.lib zlib.lib libmySQL.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_mysqli.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\release"
-
-!ENDIF
-
-# Begin Target
-
-# Name "mysqli - Win32 Release_TS"
-# Name "mysqli - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\mysqli.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysqli_api.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysqli_fe.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\mysqli_nonapi.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_mysqli.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c deleted file mode 100644 index c951cd9f96..0000000000 --- a/ext/mysqli/mysqli_api.c +++ /dev/null @@ -1,2125 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -/* {{{ proto mixed mysqli_affected_rows(object link) - Get number of affected rows in previous MySQL operation */ -PHP_FUNCTION(mysqli_affected_rows) -{ - MY_MYSQL *mysql; - zval *mysql_link; - my_ulonglong rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - rc = mysql_affected_rows(mysql->mysql); - if (rc == (my_ulonglong) -1) { - RETURN_LONG(-1); - } - MYSQLI_RETURN_LONG_LONG(rc); -} -/* }}} */ - -/* {{{ proto bool mysqli_autocommit(object link, bool mode) - Turn auto commit on or of */ -PHP_FUNCTION(mysqli_autocommit) -{ - MY_MYSQL *mysql; - zval *mysql_link; - zend_bool automode; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ob", &mysql_link, mysqli_link_class_entry, &automode) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_autocommit(mysql->mysql, (my_bool)automode)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_bind_param(object stmt, string types, mixed variable [,mixed,....]) - Bind variables to a prepared statement as parameters */ -PHP_FUNCTION(mysqli_stmt_bind_param) -{ - zval ***args; - int argc = ZEND_NUM_ARGS(); - int i; - int num_vars; - int start = 2; - int ofs; - MY_STMT *stmt; - zval *mysql_stmt; - MYSQL_BIND *bind; - char *types; - int typelen; - unsigned long rc; - - /* calculate and check number of parameters */ - if (argc < 2) { - /* there has to be at least one pair */ - WRONG_PARAM_COUNT; - } - - if (zend_parse_method_parameters((getThis()) ? 1:2 TSRMLS_CC, getThis(), "Os", &mysql_stmt, mysqli_stmt_class_entry, &types, &typelen) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - num_vars = argc - 1; - if (getThis()) { - start = 1; - } else { - /* ignore handle parameter in procedural interface*/ - --num_vars; - } - - if (typelen != argc - start) { - /* number of bind variables doesn't match number of elements in type definition string */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of elements in type definition string doesn't match number of bind variables"); - RETURN_FALSE; - } - - if (typelen != stmt->stmt->param_count) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of variables doesn't match number of parameters in prepared statement"); - RETURN_FALSE; - } - - /* prevent leak if variables are already bound */ - if (stmt->param.var_cnt) { - php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); - } - - args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); - - if (zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - stmt->param.is_null = ecalloc(num_vars, sizeof(char)); - bind = (MYSQL_BIND *)ecalloc(num_vars, sizeof(MYSQL_BIND)); - - ofs = 0; - for (i=start; i < argc; i++) { - - /* set specified type */ - switch (types[ofs]) { - case 'd': /* Double */ - bind[ofs].buffer_type = MYSQL_TYPE_DOUBLE; - bind[ofs].buffer = (gptr)&Z_DVAL_PP(args[i]); - bind[ofs].is_null = &stmt->param.is_null[ofs]; - break; - - case 'i': /* Integer */ - bind[ofs].buffer_type = MYSQL_TYPE_LONG; - bind[ofs].buffer = (gptr)&Z_LVAL_PP(args[i]); - bind[ofs].is_null = &stmt->param.is_null[ofs]; - break; - - case 'b': /* Blob (send data) */ - bind[ofs].buffer_type = MYSQL_TYPE_LONG_BLOB; - /* don't initialize is_null and length to 0 because we use ecalloc */ - break; - - case 's': /* string */ - bind[ofs].buffer_type = MYSQL_TYPE_VAR_STRING; - /* don't initialize buffer and buffer_length because we use ecalloc */ - bind[ofs].is_null = &stmt->param.is_null[ofs]; - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Undefined fieldtype %c (parameter %d)", types[ofs], i+1); - RETVAL_FALSE; - goto end; - } - ofs++; - } - rc = mysql_stmt_bind_param(stmt->stmt, bind); - MYSQLI_REPORT_STMT_ERROR(stmt->stmt); - - if (rc) { - RETVAL_FALSE; - goto end; - } - - stmt->param.var_cnt = num_vars; - stmt->param.vars = (zval **)safe_emalloc(num_vars, sizeof(zval), 0); - for (i = 0; i < num_vars; i++) { - if (bind[i].buffer_type != MYSQL_TYPE_LONG_BLOB) { - ZVAL_ADDREF(*args[i+start]); - stmt->param.vars[i] = *args[i+start]; - } else { - stmt->param.vars[i] = NULL; - } - } - RETVAL_TRUE; -end: - efree(args); - efree(bind); -} -/* }}} */ - -/* {{{ 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_stmt_bind_result) -{ - zval ***args; - int argc = ZEND_NUM_ARGS(); - int i; - int start = 1; - int var_cnt; - int ofs; - long col_type; - ulong rc; - MY_STMT *stmt; - zval *mysql_stmt; - MYSQL_BIND *bind; - - if (getThis()) { - start = 0; - } - - if (zend_parse_method_parameters((getThis()) ? 0:1 TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - if (argc < (getThis() ? 1 : 2)) { - WRONG_PARAM_COUNT; - } - - args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); - - if (zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; - } - - var_cnt = argc - start; - - if (var_cnt != mysql_stmt_field_count(stmt->stmt)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of bind variables doesn't match number of fields in prepared statement."); - efree(args); - RETURN_FALSE; - } - - /* prevent leak if variables are already bound */ - if (stmt->result.var_cnt) { - php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); - } - - bind = (MYSQL_BIND *)ecalloc(var_cnt, sizeof(MYSQL_BIND)); - { - int size; - char *p= emalloc(size= var_cnt * (sizeof(char) + sizeof(VAR_BUFFER))); - stmt->result.buf = (VAR_BUFFER *) p; - stmt->result.is_null = p + var_cnt * sizeof(VAR_BUFFER); - memset(p, 0, size); - } - - for (i=start; i < var_cnt + start ; i++) { - ofs = i - start; - col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING; - - switch (col_type) { - case MYSQL_TYPE_DOUBLE: - case MYSQL_TYPE_FLOAT: - convert_to_double_ex(args[i]); - stmt->result.buf[ofs].type = IS_DOUBLE; - 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 = stmt->result.buf[ofs].val; - bind[ofs].is_null = &stmt->result.is_null[ofs]; - break; - - case MYSQL_TYPE_NULL: - stmt->result.buf[ofs].type = IS_NULL; - /* - don't initialize to 0 : - 1. stmt->result.buf[ofs].buflen - 2. bind[ofs].buffer - 3. bind[ofs].buffer_length - because memory was allocated with ecalloc - */ - bind[ofs].buffer_type = MYSQL_TYPE_NULL; - bind[ofs].is_null = &stmt->result.is_null[ofs]; - break; - - case MYSQL_TYPE_SHORT: - case MYSQL_TYPE_TINY: - case MYSQL_TYPE_LONG: - case MYSQL_TYPE_INT24: - case MYSQL_TYPE_YEAR: - convert_to_long_ex(args[i]); - stmt->result.buf[ofs].type = IS_LONG; - /* don't set stmt->result.buf[ofs].buflen to 0, we used ecalloc */ - stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int)); - bind[ofs].buffer_type = MYSQL_TYPE_LONG; - bind[ofs].buffer = stmt->result.buf[ofs].val; - bind[ofs].is_null = &stmt->result.is_null[ofs]; - bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; - break; - - case MYSQL_TYPE_LONGLONG: -#if MYSQL_VERSION_ID > 50002 - case MYSQL_TYPE_BIT: -#endif - stmt->result.buf[ofs].type = IS_STRING; - stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); - stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); - bind[ofs].buffer_type = col_type; - 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].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; - break; - - case MYSQL_TYPE_DATE: - case MYSQL_TYPE_TIME: - case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_NEWDATE: - case MYSQL_TYPE_VAR_STRING: - case MYSQL_TYPE_STRING: - case MYSQL_TYPE_BLOB: - case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_DECIMAL: -#ifdef FIELD_TYPE_NEWDECIMAL - case MYSQL_TYPE_NEWDECIMAL: -#endif - { -#if MYSQL_VERSION_ID > 50099 - /* Changed to my_bool in MySQL 5.1. See MySQL Bug #16144 */ - my_bool tmp; -#else - ulong tmp = 0; -#endif - stmt->result.buf[ofs].type = IS_STRING; - /* - If the user has called $stmt->store_result() then we have asked - max_length to be updated. this is done only for BLOBS because we don't want to allocate - big chunkgs of memory 2^16 or 2^24 - */ - if (stmt->stmt->fields[ofs].max_length == 0 && - !mysql_stmt_attr_get(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp) && !tmp) - { - stmt->result.buf[ofs].buflen = - (stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256: 256; - } else { - /* - the user has called store_result(). if he does not there is no way to determine the - libmysql does not allow us to allocate 0 bytes for a buffer so we try 1 - */ - if (!(stmt->result.buf[ofs].buflen = stmt->stmt->fields[ofs].max_length)) - ++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].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; - break; - } - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Server returned unknown type %ld. Probably your client library is incompatible with the server version you use!", col_type); - break; - } - } - - rc = mysql_stmt_bind_result(stmt->stmt, bind); - MYSQLI_REPORT_STMT_ERROR(stmt->stmt); - - if (rc) { - /* dont close the statement or subsequent usage (for example ->execute()) will lead to crash */ - for (i=0; i < var_cnt ; i++) { - if (stmt->result.buf[i].val) { - efree(stmt->result.buf[i].val); - } - } - /* Don't free stmt->result.is_null because is_null & buf are one block of memory */ - efree(stmt->result.buf); - RETVAL_FALSE; - } else { - stmt->result.var_cnt = var_cnt; - stmt->result.vars = (zval **)safe_emalloc((var_cnt), sizeof(zval), 0); - for (i = start; i < var_cnt+start; i++) { - ofs = i-start; - ZVAL_ADDREF(*args[i]); - stmt->result.vars[ofs] = *args[i]; - } - RETVAL_TRUE; - } - efree(args); - efree(bind); -} -/* }}} */ - -/* {{{ proto bool mysqli_change_user(object link, string user, string password, string database) - Change logged-in user of the active connection */ -PHP_FUNCTION(mysqli_change_user) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - char *user, *password, *dbname; - int user_len, password_len, dbname_len; - ulong rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osss", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - rc = mysql_change_user(mysql->mysql, user, password, dbname); - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - - if (rc) { - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto string mysqli_character_set_name(object link) - Returns the name of the character set used for this connection */ -PHP_FUNCTION(mysqli_character_set_name) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_STRING((char *) mysql_character_set_name(mysql->mysql), 1); -} -/* }}} */ - -/* {{{ proto bool mysqli_close(object link) - Close connection */ -PHP_FUNCTION(mysqli_close) -{ - zval *mysql_link; - MY_MYSQL *mysql; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED); - - mysql_close(mysql->mysql); - php_clear_mysql(mysql); - efree(mysql); - MYSQLI_CLEAR_RESOURCE(&mysql_link); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_commit(object link) - Commit outstanding actions and close transaction */ -PHP_FUNCTION(mysqli_commit) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - if (mysql_commit(mysql->mysql)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_data_seek(object result, int offset) - Move internal result pointer */ -PHP_FUNCTION(mysqli_data_seek) -{ - MYSQL_RES *result; - zval *mysql_result; - long offset; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &offset) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if (result->handle && result->handle->status == MYSQL_STATUS_USE_RESULT) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT"); - RETURN_FALSE; - } - - if (offset < 0 || offset >= result->row_count) { - RETURN_FALSE; - } - - mysql_data_seek(result, offset); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_debug(string debug) -*/ -PHP_FUNCTION(mysqli_debug) -{ - char *debug; - int debug_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &debug, &debug_len) == FAILURE) { - return; - } - - mysql_debug(debug); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_dump_debug_info(object link) -*/ -PHP_FUNCTION(mysqli_dump_debug_info) -{ - MY_MYSQL *mysql; - zval *mysql_link; - ulong rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - rc = mysql_dump_debug_info(mysql->mysql); - - if (rc) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int mysqli_errno(object link) - Returns the numerical value of the error message from previous MySQL operation */ -PHP_FUNCTION(mysqli_errno) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - RETURN_LONG(mysql_errno(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto string mysqli_error(object link) - Returns the text of the error message from previous MySQL operation */ -PHP_FUNCTION(mysqli_error) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - RETURN_STRING((char *)mysql_error(mysql->mysql),1); -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_execute(object stmt) - Execute a prepared statement */ -PHP_FUNCTION(mysqli_stmt_execute) -{ - MY_STMT *stmt; - zval *mysql_stmt; - unsigned int i; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - for (i = 0; i < stmt->param.var_cnt; i++) { - if (stmt->param.vars[i]) { - if ( !(stmt->param.is_null[i] = (stmt->param.vars[i]->type == IS_NULL)) ) { - switch (stmt->stmt->params[i].buffer_type) { - case MYSQL_TYPE_VAR_STRING: - convert_to_string_ex(&stmt->param.vars[i]); - stmt->stmt->params[i].buffer = Z_STRVAL_PP(&stmt->param.vars[i]); - stmt->stmt->params[i].buffer_length = Z_STRLEN_PP(&stmt->param.vars[i]); - break; - case MYSQL_TYPE_DOUBLE: - convert_to_double_ex(&stmt->param.vars[i]); - stmt->stmt->params[i].buffer = (gptr)&Z_LVAL_PP(&stmt->param.vars[i]); - break; - case MYSQL_TYPE_LONG: - convert_to_long_ex(&stmt->param.vars[i]); - stmt->stmt->params[i].buffer = (gptr)&Z_LVAL_PP(&stmt->param.vars[i]); - break; - default: - break; - } - } - } - } - if (mysql_stmt_execute(stmt->stmt)) { - MYSQLI_REPORT_STMT_ERROR(stmt->stmt); - RETURN_FALSE; - } - - if (MyG(report_mode) & MYSQLI_REPORT_INDEX) { - php_mysqli_report_index(stmt->query, stmt->stmt->mysql->server_status TSRMLS_CC); - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto mixed mysqli_stmt_fetch(object stmt) - Fetch results from a prepared statement into the bound variables */ -PHP_FUNCTION(mysqli_stmt_fetch) -{ - MY_STMT *stmt; - zval *mysql_stmt; - unsigned int i; - ulong ret; - unsigned int uval; - my_ulonglong llval; - - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - /* reset buffers */ - - - for (i = 0; i < stmt->result.var_cnt; i++) { - if (stmt->result.buf[i].type == IS_STRING) { - memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen); - } - } - ret = mysql_stmt_fetch(stmt->stmt); -#ifdef MYSQL_DATA_TRUNCATED - if (!ret || ret == MYSQL_DATA_TRUNCATED) { -#else - if (!ret) { -#endif - for (i = 0; i < stmt->result.var_cnt; i++) { - /* Even if the string is of length zero there is one byte alloced so efree() in all cases */ - if (Z_TYPE_P(stmt->result.vars[i]) == IS_STRING) { - efree(stmt->result.vars[i]->value.str.val); - } - if (!stmt->result.is_null[i]) { - switch (stmt->result.buf[i].type) { - case IS_LONG: - if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG) - && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)) - { - /* unsigned int (11) */ - uval= *(unsigned int *) stmt->result.buf[i].val; - - if (uval > INT_MAX) { - char *tmp, *p; - int j=10; - tmp= emalloc(11); - p= &tmp[9]; - do { - *p-- = (uval % 10) + 48; - uval = uval / 10; - } while (--j > 0); - tmp[10]= '\0'; - /* unsigned int > INT_MAX is 10 digis - ALWAYS */ - ZVAL_STRINGL(stmt->result.vars[i], tmp, 10, 0); - break; - } - } - if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) { - ZVAL_LONG(stmt->result.vars[i], *(unsigned int *)stmt->result.buf[i].val); - } else { - ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val); - } - break; - case IS_DOUBLE: - ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val); - break; - case IS_STRING: - if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG) { - my_bool uns= (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0; - llval= *(my_ulonglong *) stmt->result.buf[i].val; -#if SIZEOF_LONG==8 - if (uns && llval > 9223372036854775807L) { -#elif SIZEOF_LONG==4 - if ((uns && llval > L64(2147483647)) || - (!uns && (( L64(2147483647) < (my_longlong) llval) || (L64(-2147483648) > (my_longlong) llval)))) - { -#endif - char tmp[22]; - /* even though lval is declared as unsigned, the value - * may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must - * use MYSQLI_LL_SPEC. - */ - sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); - ZVAL_STRING(stmt->result.vars[i], tmp, 1); - } else { - ZVAL_LONG(stmt->result.vars[i], llval); - } - } -#if MYSQL_VERSION_ID > 50002 - else if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) { - llval = *(my_ulonglong *)stmt->result.buf[i].val; - ZVAL_LONG(stmt->result.vars[i], llval); - } -#endif - else { - ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val, stmt->result.buf[i].buflen, 1); - } - break; - default: - break; - } - } else { - ZVAL_NULL(stmt->result.vars[i]); - } - } - } else { - MYSQLI_REPORT_STMT_ERROR(stmt->stmt); - } - - switch (ret) { - case 0: -#ifdef MYSQL_DATA_TRUNCATED - /* according to SQL standard truncation (e.g. loss of precision is - not an error) - for detecting possible truncation you have to - check mysqli_stmt_warning - */ - case MYSQL_DATA_TRUNCATED: -#endif - RETURN_TRUE; - break; - case 1: - RETURN_FALSE; - break; - default: - RETURN_NULL(); - break; - } -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_field (object result) - Get column information from a result and return as an object */ -PHP_FUNCTION(mysqli_fetch_field) -{ - MYSQL_RES *result; - zval *mysql_result; - MYSQL_FIELD *field; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if (!(field = mysql_fetch_field(result))) { - RETURN_FALSE; - } - - object_init(return_value); - - add_property_string(return_value, "name",(field->name ? field->name : ""), 1); - add_property_string(return_value, "orgname",(field->org_name ? field->org_name : ""), 1); - add_property_string(return_value, "table",(field->table ? field->table : ""), 1); - add_property_string(return_value, "orgtable",(field->org_table ? field->org_table : ""), 1); - add_property_string(return_value, "def",(field->def ? field->def : ""), 1); - add_property_long(return_value, "max_length", field->max_length); - add_property_long(return_value, "length", field->length); - add_property_long(return_value, "charsetnr", field->charsetnr); - add_property_long(return_value, "flags", field->flags); - add_property_long(return_value, "type", field->type); - add_property_long(return_value, "decimals", field->decimals); -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_fields (object result) - Return array of objects containing field meta-data */ -PHP_FUNCTION(mysqli_fetch_fields) -{ - MYSQL_RES *result; - zval *mysql_result; - MYSQL_FIELD *field; - zval *obj; - - unsigned int i; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - array_init(return_value); - - for (i = 0; i < mysql_num_fields(result); i++) { - field = mysql_fetch_field_direct(result, i); - - - MAKE_STD_ZVAL(obj); - object_init(obj); - - add_property_string(obj, "name",(field->name ? field->name : ""), 1); - add_property_string(obj, "orgname",(field->org_name ? field->org_name : ""), 1); - add_property_string(obj, "table",(field->table ? field->table : ""), 1); - add_property_string(obj, "orgtable",(field->org_table ? field->org_table : ""), 1); - add_property_string(obj, "def",(field->def ? field->def : ""), 1); - add_property_long(obj, "max_length", field->max_length); - add_property_long(obj, "length", field->length); - add_property_long(obj, "charsetnr", field->charsetnr); - add_property_long(obj, "flags", field->flags); - add_property_long(obj, "type", field->type); - add_property_long(obj, "decimals", field->decimals); - - add_index_zval(return_value, i, obj); - } -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_field_direct (object result, int offset) - Fetch meta-data for a single field */ -PHP_FUNCTION(mysqli_fetch_field_direct) -{ - MYSQL_RES *result; - zval *mysql_result; - MYSQL_FIELD *field; - long offset; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &offset) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if (offset < 0 || offset >= mysql_num_fields(result)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field offset is invalid for resultset"); - RETURN_FALSE; - } - - if (!(field = mysql_fetch_field_direct(result,offset))) { - RETURN_FALSE; - } - - object_init(return_value); - - add_property_string(return_value, "name",(field->name ? field->name : ""), 1); - add_property_string(return_value, "orgname",(field->org_name ? field->org_name : ""), 1); - add_property_string(return_value, "table",(field->table ? field->table : ""), 1); - add_property_string(return_value, "orgtable",(field->org_table ? field->org_table : ""), 1); - add_property_string(return_value, "def",(field->def ? field->def : ""), 1); - add_property_long(return_value, "max_length", field->max_length); - add_property_long(return_value, "length", field->length); - add_property_long(return_value, "charsetnr", field->charsetnr); - add_property_long(return_value, "flags", field->flags); - add_property_long(return_value, "type", field->type); - add_property_long(return_value, "decimals", field->decimals); -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_lengths (object result) - Get the length of each output in a result */ -PHP_FUNCTION(mysqli_fetch_lengths) -{ - MYSQL_RES *result; - zval *mysql_result; - unsigned int i; - unsigned long *ret; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if (!(ret = mysql_fetch_lengths(result))) { - RETURN_FALSE; - } - - array_init(return_value); - - for (i = 0; i < mysql_num_fields(result); i++) { - add_index_long(return_value, i, ret[i]); - } -} -/* }}} */ - -/* {{{ proto array mysqli_fetch_row (object result) - Get a result row as an enumerated array */ -PHP_FUNCTION(mysqli_fetch_row) -{ - php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_NUM, 0); -} -/* }}} */ - -/* {{{ proto int mysqli_field_count(object link) - Fetch the number of fields returned by the last query for the given link -*/ -PHP_FUNCTION(mysqli_field_count) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_field_count(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto int mysqli_field_seek(object result, int fieldnr) - Set result pointer to a specified field offset -*/ -PHP_FUNCTION(mysqli_field_seek) -{ - MYSQL_RES *result; - zval *mysql_result; - unsigned long fieldnr; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &fieldnr) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if (fieldnr < 0 || fieldnr >= mysql_num_fields(result)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid field offset"); - RETURN_FALSE; - } - - mysql_field_seek(result, fieldnr); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int mysqli_field_tell(object result) - Get current field offset of result pointer */ -PHP_FUNCTION(mysqli_field_tell) -{ - MYSQL_RES *result; - zval *mysql_result; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_field_tell(result)); -} -/* }}} */ - -/* {{{ proto void mysqli_free_result(object result) - Free query result memory for the given result handle */ -PHP_FUNCTION(mysqli_free_result) -{ - MYSQL_RES *result; - zval *mysql_result; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - mysql_free_result(result); - MYSQLI_CLEAR_RESOURCE(&mysql_result); -} -/* }}} */ - -/* {{{ proto string mysqli_get_client_info(void) - Get MySQL client info */ -PHP_FUNCTION(mysqli_get_client_info) -{ - RETURN_STRING((char *)mysql_get_client_info(), 1); -} -/* }}} */ - -/* {{{ proto int mysqli_get_client_version(void) - Get MySQL client info */ -PHP_FUNCTION(mysqli_get_client_version) -{ - RETURN_LONG((long)mysql_get_client_version()); -} -/* }}} */ - -/* {{{ proto string mysqli_get_host_info (object link) - Get MySQL host info */ -PHP_FUNCTION(mysqli_get_host_info) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_STRING((mysql->mysql->host_info) ? mysql->mysql->host_info : "", 1); -} -/* }}} */ - -/* {{{ proto int mysqli_get_proto_info(object link) - Get MySQL protocol information */ -PHP_FUNCTION(mysqli_get_proto_info) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_get_proto_info(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto string mysqli_get_server_info(object link) - Get MySQL server info */ -PHP_FUNCTION(mysqli_get_server_info) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_STRING((char *)mysql_get_server_info(mysql->mysql), 1); -} - -/* }}} */ - -/* {{{ proto int mysqli_get_server_version(object link) - Return the MySQL version for the server referenced by the given link */ -PHP_FUNCTION(mysqli_get_server_version) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_get_server_version(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto string mysqli_info(object link) - Get information about the most recent query */ -PHP_FUNCTION(mysqli_info) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_STRING((mysql->mysql->info) ? mysql->mysql->info : "", 1); -} -/* }}} */ - -/* {{{ proto resource mysqli_init(void) - Initialize mysqli and return a resource for use with mysql_real_connect */ -PHP_FUNCTION(mysqli_init) -{ - MYSQLI_RESOURCE *mysqli_resource; - MY_MYSQL *mysql = (MY_MYSQL *)ecalloc(1, sizeof(MY_MYSQL)); - - if (!(mysql->mysql = mysql_init(NULL))) { - efree(mysql); - RETURN_FALSE; - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)mysql; - mysqli_resource->status = MYSQLI_STATUS_INITIALIZED; - - if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_link_class_entry TSRMLS_CC)) { - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); - } else { - ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource; - } -} -/* }}} */ - -/* {{{ proto mixed mysqli_insert_id(object link) - Get the ID generated from the previous INSERT operation */ -PHP_FUNCTION(mysqli_insert_id) -{ - MY_MYSQL *mysql; - my_ulonglong rc; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - rc = mysql_insert_id(mysql->mysql); - MYSQLI_RETURN_LONG_LONG(rc) -} -/* }}} */ - -/* {{{ proto bool mysqli_kill(object link, int processid) - Kill a mysql process on the server */ -PHP_FUNCTION(mysqli_kill) -{ - MY_MYSQL *mysql; - zval *mysql_link; - long processid; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &processid) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_kill(mysql->mysql, processid)) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_set_local_infile_default(object link) - unsets user defined handler for load local infile command */ -PHP_FUNCTION(mysqli_set_local_infile_default) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql->li_read) { - efree(Z_STRVAL_P(mysql->li_read)); - zval_dtor(mysql->li_read); - mysql->li_read = NULL; - } -} -/* }}} */ - -/* {{{ proto bool mysqli_set_local_infile_handler(object link, callback read_func) - Set callback functions for LOAD DATA LOCAL INFILE */ -PHP_FUNCTION(mysqli_set_local_infile_handler) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *callback_name; - zval *callback_func; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz", &mysql_link, mysqli_link_class_entry, - &callback_func) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - /* check callback function */ - if (!zend_is_callable(callback_func, 0, &callback_name)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a valid callback function %s", callback_name); - efree(callback_name); - RETURN_FALSE; - } - efree(callback_name); - - /* save callback function */ - ALLOC_ZVAL(mysql->li_read); - ZVAL_STRING(mysql->li_read, callback_func->value.str.val, 1); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_more_results(object link) - check if there any more query results from a multi query */ -PHP_FUNCTION(mysqli_more_results) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_BOOL(mysql_more_results(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto bool mysqli_next_result(object link) - read next result from multi_query */ -PHP_FUNCTION(mysqli_next_result) { - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_BOOL(!mysql_next_result(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto int mysqli_num_fields(object result) - Get number of fields in result */ -PHP_FUNCTION(mysqli_num_fields) -{ - MYSQL_RES *result; - zval *mysql_result; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_num_fields(result)); -} -/* }}} */ - -/* {{{ proto mixed mysqli_num_rows(object result) - Get number of rows in result */ -PHP_FUNCTION(mysqli_num_rows) -{ - MYSQL_RES *result; - zval *mysql_result; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); - - if (result->handle && result->handle->status == MYSQL_STATUS_USE_RESULT) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT"); - RETURN_LONG(0); - } - - MYSQLI_RETURN_LONG_LONG(mysql_num_rows(result)); -} -/* }}} */ - -/* {{{ proto bool mysqli_options(object link, int flags, mixed values) - Set options */ -PHP_FUNCTION(mysqli_options) -{ - MY_MYSQL *mysql; - zval *mysql_link = NULL; - zval *mysql_value; - long mysql_option; - unsigned int l_value; - long ret; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olz", &mysql_link, mysqli_link_class_entry, &mysql_option, &mysql_value) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED); - - switch (Z_TYPE_PP(&mysql_value)) { - case IS_STRING: - ret = mysql_options(mysql->mysql, mysql_option, Z_STRVAL_PP(&mysql_value)); - break; - default: - convert_to_long_ex(&mysql_value); - l_value = Z_LVAL_PP(&mysql_value); - ret = mysql_options(mysql->mysql, mysql_option, (char *)&l_value); - break; - } - - RETURN_BOOL(!ret); -} -/* }}} */ - - -/* {{{ proto bool mysqli_ping(object link) - Ping a server connection or reconnect if there is no connection */ -PHP_FUNCTION(mysqli_ping) -{ - MY_MYSQL *mysql; - zval *mysql_link; - long rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - rc = mysql_ping(mysql->mysql); - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - - RETURN_BOOL(!rc); -} -/* }}} */ - -/* {{{ proto mixed mysqli_prepare(object link, string query) - Prepare a SQL statement for execution */ -PHP_FUNCTION(mysqli_prepare) -{ - MY_MYSQL *mysql; - MY_STMT *stmt; - char *query = NULL; - unsigned int query_len; - zval *mysql_link; - MYSQLI_RESOURCE *mysqli_resource; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",&mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - if (mysql->mysql->status == MYSQL_STATUS_GET_RESULT) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "All data must be fetched before a new statement prepare takes place"); - RETURN_FALSE; - } - - stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT)); - - if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) { - if (mysql_stmt_prepare(stmt->stmt, query, query_len)) { - char last_error[MYSQL_ERRMSG_SIZE]; - char sqlstate[SQLSTATE_LENGTH+1]; - unsigned int last_errno; - - /* mysql_stmt_close clears errors, so we have to store them temporarily */ - last_errno = stmt->stmt->last_errno; - memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE); - memcpy(sqlstate, mysql->mysql->net.sqlstate, SQLSTATE_LENGTH+1); - - mysql_stmt_close(stmt->stmt); - stmt->stmt = NULL; - - /* restore error messages */ - mysql->mysql->net.last_errno = last_errno; - memcpy(mysql->mysql->net.last_error, last_error, MYSQL_ERRMSG_SIZE); - memcpy(mysql->mysql->net.sqlstate, sqlstate, SQLSTATE_LENGTH+1); - } - } - /* don't joing to the previous if because it won't work if mysql_stmt_prepare_fails */ - if (!stmt->stmt) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - efree(stmt); - RETURN_FALSE; - } - - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)stmt; - /* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */ - /* Get performance boost if reporting is switched off */ - if (query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) { - stmt->query = (char *)emalloc(query_len + 1); - memcpy(stmt->query, query, query_len); - stmt->query[query_len] = '\0'; - } - - /* change status */ - mysqli_resource->status = MYSQLI_STATUS_VALID; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_stmt_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) -{ - MY_MYSQL *mysql; - char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL; - unsigned int hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0; - unsigned long port=0, flags=0; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sssslsl", &mysql_link, mysqli_link_class_entry, - &hostname, &hostname_len, &username, &username_len, &passwd, &passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len, - &flags) == FAILURE) { - return; - } - - if (!socket_len) { - socket = NULL; - } - - /* TODO: safe mode handling */ - if (PG(sql_safe_mode)) { - } else { - if (!passwd) { - passwd = MyG(default_pw); - if (!username){ - username = MyG(default_user); - if (!hostname) { - hostname = MyG(default_host); - } - } - } - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED); - - /* remove some insecure options */ - flags ^= CLIENT_MULTI_STATEMENTS; /* don't allow multi_queries via connect parameter */ - if (PG(open_basedir) && strlen(PG(open_basedir))) { - flags ^= CLIENT_LOCAL_FILES; - } - - if (!socket) { - socket = MyG(default_socket); - } - - if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,flags) == NULL) { - php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC); - php_mysqli_throw_sql_exception( mysql->mysql->net.sqlstate, mysql->mysql->net.last_errno TSRMLS_CC, - "%s", mysql->mysql->net.last_error); - - /* change status */ - MYSQLI_SET_STATUS(&mysql_link, MYSQLI_STATUS_INITIALIZED); - RETURN_FALSE; - } - - php_mysqli_set_error(mysql_errno(mysql->mysql), (char *)mysql_error(mysql->mysql) TSRMLS_CC); - - mysql->mysql->reconnect = MyG(reconnect); - - /* set our own local_infile handler */ - php_set_local_infile_handler_default(mysql); - - /* change status */ - MYSQLI_SET_STATUS(&mysql_link, MYSQLI_STATUS_VALID); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_real_query(object link, string query) - Binary-safe version of mysql_query() */ -PHP_FUNCTION(mysqli_real_query) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *query = NULL; - unsigned int query_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - MYSQLI_DISABLE_MQ; /* disable multi statements/queries */ - - if (mysql_real_query(mysql->mysql, query, query_len)) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - RETURN_FALSE; - } - - if (!mysql_field_count(mysql->mysql)) { - if (MyG(report_mode) & MYSQLI_REPORT_INDEX) { - php_mysqli_report_index(query, mysql->mysql->server_status TSRMLS_CC); - } - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto string mysqli_real_escape_string(object link, string escapestr) - Escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection */ -PHP_FUNCTION(mysqli_real_escape_string) { - MY_MYSQL *mysql; - zval *mysql_link = NULL; - char *escapestr, *newstr; - int escapestr_len, newstr_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &escapestr, &escapestr_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - newstr = safe_emalloc(2, escapestr_len, 1); - newstr_len = mysql_real_escape_string(mysql->mysql, newstr, escapestr, escapestr_len); - newstr = erealloc(newstr, newstr_len + 1); - - RETURN_STRINGL(newstr, newstr_len, 0); -} -/* }}} */ - -/* {{{ proto bool mysqli_rollback(object link) - Undo actions from current transaction */ -PHP_FUNCTION(mysqli_rollback) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_rollback(mysql->mysql)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_send_long_data(object stmt, int param_nr, string data) -*/ -PHP_FUNCTION(mysqli_stmt_send_long_data) -{ - MY_STMT *stmt; - zval *mysql_stmt; - char *data; - long param_nr; - int data_len; - - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ols", &mysql_stmt, mysqli_stmt_class_entry, ¶m_nr, &data, &data_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - if (param_nr < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter number"); - RETURN_FALSE; - } - if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - - -/* {{{ proto mixed mysqli_stmt_affected_rows(object stmt) - Return the number of rows affected in the last query for the given link */ -PHP_FUNCTION(mysqli_stmt_affected_rows) -{ - MY_STMT *stmt; - zval *mysql_stmt; - my_ulonglong rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - rc = mysql_stmt_affected_rows(stmt->stmt); - if (rc == (my_ulonglong) -1) { - RETURN_LONG(-1); - } - MYSQLI_RETURN_LONG_LONG(rc) -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_close(object stmt) - Close statement */ -PHP_FUNCTION(mysqli_stmt_close) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - mysql_stmt_close(stmt->stmt); - stmt->stmt = NULL; - php_clear_stmt_bind(stmt); - MYSQLI_CLEAR_RESOURCE(&mysql_stmt); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_stmt_data_seek(object stmt, int offset) - Move internal result pointer */ -PHP_FUNCTION(mysqli_stmt_data_seek) -{ - MY_STMT *stmt; - zval *mysql_stmt; - long offset; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &offset) == FAILURE) { - return; - } - if (offset < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be positive"); - RETURN_FALSE; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - mysql_stmt_data_seek(stmt->stmt, offset); -} -/* }}} */ - -/* {{{ proto int mysqli_stmt_field_count(object stmt) { - Return the number of result columns for the given statement */ -PHP_FUNCTION(mysqli_stmt_field_count) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_stmt_field_count(stmt->stmt)); -} -/* }}} */ - -/* {{{ proto void mysqli_stmt_free_result(object stmt) - Free stored result memory for the given statement handle */ -PHP_FUNCTION(mysqli_stmt_free_result) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - mysql_stmt_free_result(stmt->stmt); -} -/* }}} */ - -/* {{{ proto mixed mysqli_stmt_insert_id(object stmt) - Get the ID generated from the previous INSERT operation */ -PHP_FUNCTION(mysqli_stmt_insert_id) -{ - MY_STMT *stmt; - my_ulonglong rc; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - rc = mysql_stmt_insert_id(stmt->stmt); - MYSQLI_RETURN_LONG_LONG(rc) -} -/* }}} */ - -/* {{{ proto int mysqli_stmt_param_count(object stmt) { - Return the number of parameter for the given statement */ -PHP_FUNCTION(mysqli_stmt_param_count) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_stmt_param_count(stmt->stmt)); -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_reset(object stmt) - reset a prepared statement */ -PHP_FUNCTION(mysqli_stmt_reset) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - if (mysql_stmt_reset(stmt->stmt)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto mixed mysqli_stmt_num_rows(object stmt) - Return the number of rows in statements result set */ -PHP_FUNCTION(mysqli_stmt_num_rows) -{ - MY_STMT *stmt; - zval *mysql_stmt; - my_ulonglong rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - rc = mysql_stmt_num_rows(stmt->stmt); - MYSQLI_RETURN_LONG_LONG(rc) -} -/* }}} */ - -/* {{{ proto string mysqli_select_db(object link, string dbname) - Select a MySQL database */ -PHP_FUNCTION(mysqli_select_db) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *dbname; - int dbname_len; - - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &dbname, &dbname_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (!mysql_select_db(mysql->mysql, dbname)) { - RETURN_TRUE; - } - - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string mysqli_sqlstate(object link) - Returns the SQLSTATE error from previous MySQL operation */ -PHP_FUNCTION(mysqli_sqlstate) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - RETURN_STRING((char *)mysql_sqlstate(mysql->mysql),1); -} -/* }}} */ - -/* {{{ proto bool mysqli_ssl_set(object link ,string key ,string cert ,string ca ,string capath ,string cipher]) -*/ -PHP_FUNCTION(mysqli_ssl_set) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *ssl_parm[5]; - int ssl_parm_len[5], i; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osssss", &mysql_link, mysqli_link_class_entry, &ssl_parm[0], &ssl_parm_len[0], &ssl_parm[1], &ssl_parm_len[1], &ssl_parm[2], &ssl_parm_len[2], &ssl_parm[3], &ssl_parm_len[3], &ssl_parm[4], &ssl_parm_len[4]) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_INITIALIZED); - - for (i=0; i < 5; i++) { - if (!ssl_parm_len[i]) { - ssl_parm[i] = NULL; - } - } - - mysql_ssl_set(mysql->mysql, ssl_parm[0], ssl_parm[1], ssl_parm[2], ssl_parm[3], ssl_parm[4]); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto mixed mysqli_stat(object link) - Get current system status */ -PHP_FUNCTION(mysqli_stat) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *stat; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if ((stat = (char *)mysql_stat(mysql->mysql))) { - RETURN_STRING(stat, 1); - } - RETURN_FALSE; -} - -/* }}} */ - -/* {{{ proto int mysqli_stmt_attr_set(object stmt, long attr, long mode) -*/ -PHP_FUNCTION(mysqli_stmt_attr_set) -{ - MY_STMT *stmt; - zval *mysql_stmt; - ulong mode; - ulong attr; - int rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - if ((rc = mysql_stmt_attr_set(stmt->stmt, attr, (void *)&mode))) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int mysqli_stmt_attr_get(object stmt, long attr) -*/ -PHP_FUNCTION(mysqli_stmt_attr_get) -{ - MY_STMT *stmt; - zval *mysql_stmt; -#if MYSQL_VERSION_ID > 50099 - my_bool value; -#else - ulong value = 0; -#endif - ulong attr; - int rc; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &mysql_stmt, mysqli_stmt_class_entry, &attr) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) { - RETURN_FALSE; - } - RETURN_LONG((long)value); -} -/* }}} */ - -/* {{{ proto int mysqli_stmt_errno(object stmt) -*/ -PHP_FUNCTION(mysqli_stmt_errno) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED); - - RETURN_LONG(mysql_stmt_errno(stmt->stmt)); -} -/* }}} */ - -/* {{{ proto string mysqli_stmt_error(object stmt) -*/ -PHP_FUNCTION(mysqli_stmt_error) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED); - - RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1); -} -/* }}} */ - -/* {{{ proto mixed mysqli_stmt_init(object link) - Initialize statement object -*/ -PHP_FUNCTION(mysqli_stmt_init) -{ - MY_MYSQL *mysql; - MY_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, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT)); - - if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) { - efree(stmt); - RETURN_FALSE; - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->status = MYSQLI_STATUS_INITIALIZED; - mysqli_resource->ptr = (void *)stmt; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_stmt_class_entry); -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_prepare(object stmt, string query) - prepare server side statement with query -*/ -PHP_FUNCTION(mysqli_stmt_prepare) -{ - MY_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, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED); - - if (mysql_stmt_prepare(stmt->stmt, query, query_len)) { - MYSQLI_REPORT_STMT_ERROR(stmt->stmt); - RETURN_FALSE; - } - /* change status */ - MYSQLI_SET_STATUS(&mysql_stmt, MYSQLI_STATUS_VALID); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto mixed mysqli_stmt_result_metadata(object stmt) - return result set from statement */ -PHP_FUNCTION(mysqli_stmt_result_metadata) -{ - MY_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, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - if (!(result = mysql_stmt_result_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_resource->status = MYSQLI_STATUS_VALID; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry); -} -/* }}} */ - -/* {{{ proto bool mysqli_stmt_store_result(stmt) -*/ -PHP_FUNCTION(mysqli_stmt_store_result) -{ - MY_STMT *stmt; - zval *mysql_stmt; - int i=0; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - /* - If the user wants to store the data and we have BLOBs/TEXTs we try to allocate - not the maximal length of the type (which is 16MB even for LONGBLOB) but - the maximal length of the field in the result set. If he/she has quite big - BLOB/TEXT columns after calling store_result() the memory usage of PHP will - double - but this is a known problem of the simple MySQL API ;) - */ - for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) { - if (stmt->stmt->fields && stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB) { - my_bool tmp=1; - mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp); - break; - } - } - - if (mysql_stmt_store_result(stmt->stmt)){ - MYSQLI_REPORT_STMT_ERROR(stmt->stmt); - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto string mysqli_stmt_sqlstate(object stmt) -*/ -PHP_FUNCTION(mysqli_stmt_sqlstate) -{ - MY_STMT *stmt; - zval *mysql_stmt; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); - - RETURN_STRING((char *)mysql_stmt_sqlstate(stmt->stmt),1); -} -/* }}} */ - -/* {{{ proto object mysqli_store_result(object link) - Buffer result set on client */ -PHP_FUNCTION(mysqli_store_result) -{ - MY_MYSQL *mysql; - MYSQL_RES *result; - 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, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (!(result = mysql_store_result(mysql->mysql))) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - RETURN_FALSE; - } - if (MyG(report_mode) & MYSQLI_REPORT_INDEX) { - php_mysqli_report_index("from previous query", mysql->mysql->server_status TSRMLS_CC); - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)result; - mysqli_resource->status = MYSQLI_STATUS_VALID; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry); -} -/* }}} */ - -/* {{{ proto int mysqli_thread_id(object link) - Return the current thread ID */ -PHP_FUNCTION(mysqli_thread_id) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_thread_id(mysql->mysql)); -} -/* }}} */ - -/* {{{ proto bool mysqli_thread_safe(void) - Return whether thread safety is given or not */ -PHP_FUNCTION(mysqli_thread_safe) -{ - RETURN_BOOL(mysql_thread_safe()); -} - -/* }}} */ - -/* {{{ proto mixed mysqli_use_result(object link) - Directly retrieve query results - do not buffer results on client side */ -PHP_FUNCTION(mysqli_use_result) -{ - MY_MYSQL *mysql; - MYSQL_RES *result; - 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, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (!(result = mysql_use_result(mysql->mysql))) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - RETURN_FALSE; - } - - if (MyG(report_mode) & MYSQLI_REPORT_INDEX) { - php_mysqli_report_index("from previous query", mysql->mysql->server_status TSRMLS_CC); - } - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)result; - mysqli_resource->status = MYSQLI_STATUS_VALID; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry); -} -/* }}} */ - -/* {{{ proto int mysqli_warning_count (object link) - Return number of warnings from the last query for the given link */ -PHP_FUNCTION(mysqli_warning_count) -{ - MY_MYSQL *mysql; - zval *mysql_link; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_warning_count(mysql->mysql)); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_driver.c b/ext/mysqli/mysqli_driver.c deleted file mode 100644 index 7a16e6284e..0000000000 --- a/ext/mysqli/mysqli_driver.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - -*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" -#include "zend_exceptions.h" - - -#define MAP_PROPERTY_MYG_BOOL_READ(name, value) \ -static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \ -{ \ - ALLOC_ZVAL(*retval); \ - ZVAL_BOOL(*retval, MyG(value)); \ - return SUCCESS; \ -} \ - -#define MAP_PROPERTY_MYG_BOOL_WRITE(name, value) \ -static int name(mysqli_object *obj, zval *value TSRMLS_DC) \ -{ \ - MyG(value) = Z_LVAL_P(value) > 0; \ - return SUCCESS; \ -} \ - -#define MAP_PROPERTY_MYG_LONG_READ(name, value) \ -static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \ -{ \ - ALLOC_ZVAL(*retval); \ - ZVAL_LONG(*retval, MyG(value)); \ - return SUCCESS; \ -} \ - -#define MAP_PROPERTY_MYG_LONG_WRITE(name, value) \ -static int name(mysqli_object *obj, zval *value TSRMLS_DC) \ -{ \ - MyG(value) = Z_LVAL_P(value); \ - return SUCCESS; \ -} \ - -#define MAP_PROPERTY_MYG_STRING_READ(name, value) \ -static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \ -{ \ - ALLOC_ZVAL(*retval); \ - ZVAL_STRING(*retval, MyG(value), 1); \ - return SUCCESS; \ -} \ - -#define MAP_PROPERTY_MYG_STRING_WRITE(name, value) \ -static int name(mysqli_object *obj, zval *value TSRMLS_DC) \ -{ \ - MyG(value) = Z_STRVAL_P(value); \ - return SUCCESS; \ -} \ - -/* {{{ property driver_report_write */ -static int driver_report_write(mysqli_object *obj, zval *value TSRMLS_DC) -{ - MyG(report_mode) = Z_LVAL_P(value); - php_set_error_handling(MyG(report_mode) & MYSQLI_REPORT_STRICT ? EH_THROW : EH_NORMAL, - zend_exception_get_default(TSRMLS_C) TSRMLS_CC); - return SUCCESS; -} -/* }}} */ - -/* {{{ property driver_embedded_read */ -static int driver_embedded_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); -#ifdef HAVE_EMBEDDED_MYSQLI - ZVAL_BOOL(*retval, 1); -#else - ZVAL_BOOL(*retval, 0); -#endif - return SUCCESS; -} -/* }}} */ - -/* {{{ property driver_client_version_read */ -static int driver_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_LONG(*retval, MYSQL_VERSION_ID); - return SUCCESS; -} -/* }}} */ - -/* {{{ property driver_client_info_read */ -static int driver_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, MYSQL_SERVER_VERSION, 1); - return SUCCESS; -} -/* }}} */ - -/* {{{ property driver_driver_version_read */ -static int driver_driver_version_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_LONG(*retval, MYSQLI_VERSION_ID); - return SUCCESS; -} -/* }}} */ - -MAP_PROPERTY_MYG_BOOL_READ(driver_reconnect_read, reconnect); -MAP_PROPERTY_MYG_BOOL_WRITE(driver_reconnect_write, reconnect); -MAP_PROPERTY_MYG_LONG_READ(driver_report_read, report_mode); - -ZEND_FUNCTION(mysqli_driver_construct) -{ -} - -mysqli_property_entry mysqli_driver_property_entries[] = { - {"client_info", driver_client_info_read, NULL}, - {"client_version", driver_client_version_read, NULL}, - {"driver_version", driver_driver_version_read, NULL}, - {"embedded", driver_embedded_read, NULL}, - {"reconnect", driver_reconnect_read, driver_reconnect_write}, - {"report_mode", driver_report_read, driver_report_write}, - {NULL, NULL, NULL} -}; - -/* {{{ mysqli_driver_methods[] - */ -zend_function_entry mysqli_driver_methods[] = { - PHP_FALIAS(embedded_server_start, mysqli_embedded_server_start, NULL) - PHP_FALIAS(embedded_server_end, mysqli_embedded_server_end, NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_embedded.c b/ext/mysqli/mysqli_embedded.c deleted file mode 100644 index 71f55d676f..0000000000 --- a/ext/mysqli/mysqli_embedded.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - -*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -/* {{{ proto bool mysqli_embedded_server_start(bool start, array arguments, array groups) - initialize and start embedded server */ -PHP_FUNCTION(mysqli_embedded_server_start) -{ -#ifdef HAVE_EMBEDDED_MYSQLI - int argc = 0; - char **arguments; - char **groups; - zval **args, **grps, **start; - HashPosition pos; - int index, rc; - - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &start, &args, &grps) == FAILURE) { - ZEND_WRONG_PARAM_COUNT(); - } - - convert_to_long_ex(start); - convert_to_array_ex(args); - convert_to_array_ex(grps); - - if (!Z_LVAL_PP(start)) { - mysql_server_init(-1,NULL, NULL); - RETURN_TRUE; - } - /* get arguments */ - if ((argc = zend_hash_num_elements(HASH_OF(*args)))) { - arguments = safe_emalloc(sizeof(char *), argc + 1, 0); - arguments[0] = NULL; - - zend_hash_internal_pointer_reset_ex(HASH_OF(*args), &pos); - - for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*args), &pos)) { - zval **item; - - if (zend_hash_get_current_data_ex(HASH_OF(*args), (void **) &item, &pos) == FAILURE) { - break; - } - - convert_to_string_ex(item); - - arguments[++index] = Z_STRVAL_PP(item); - } - argc++; - } - - /* get groups */ - if ((zend_hash_num_elements(HASH_OF(*grps)))) { - groups = safe_emalloc(sizeof(char *), zend_hash_num_elements(HASH_OF(*grps)) + 1, 0); - groups[0] = NULL; - - zend_hash_internal_pointer_reset_ex(HASH_OF(*grps), &pos); - - for (index = 0;; zend_hash_move_forward_ex(HASH_OF(*grps), &pos)) { - zval ** item; - - if (zend_hash_get_current_data_ex(HASH_OF(*grps), (void **) &item, &pos) == FAILURE) { - break; - } - - convert_to_string_ex(item); - - groups[++index] = Z_STRVAL_PP(item); - } - groups[index] = NULL; - } else { - groups = safe_emalloc(sizeof(char *), 1, 0); - groups[0] = NULL; - } - - rc = mysql_server_init(argc, arguments, groups); - - if (argc) { - efree(arguments); - } - efree(groups); - - if (rc) { - RETURN_FALSE; - } - RETURN_TRUE; -#endif -} -/* }}} */ - -/* {{{ proto void mysqli_embedded_server_end(void) -*/ -PHP_FUNCTION(mysqli_embedded_server_end) -{ -#ifdef HAVE_MYSQLI_EMBEDDED - mysql_server_end(); -#endif -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_exception.c b/ext/mysqli/mysqli_exception.c deleted file mode 100644 index 4b18775298..0000000000 --- a/ext/mysqli/mysqli_exception.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - -*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" -#include "zend_exceptions.h" - -/* {{{ mysqli_exception_methods[] - */ -zend_function_entry mysqli_exception_methods[] = { - {NULL, NULL, NULL} -}; -/* }}} */ - -void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...) -{ - zval *sql_ex; - va_list arg; - char *message; - - va_start(arg, format); - vspprintf(&message, 0, format, arg); - va_end(arg);; - - if (!(MyG(report_mode) & MYSQLI_REPORT_STRICT)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%s/%d): %s", sqlstate, errorno, message); - efree(message); - return; - } - - MAKE_STD_ZVAL(sql_ex); - object_init_ex(sql_ex, mysqli_exception_class_entry); - - if (message) { - zend_update_property_string(mysqli_exception_class_entry, sql_ex, "message", sizeof("message") - 1, - message TSRMLS_CC); - } - - if (sqlstate) { - zend_update_property_string(mysqli_exception_class_entry, sql_ex, "sqlstate", sizeof("sqlstate") - 1, - sqlstate TSRMLS_CC); - } else { - zend_update_property_string(mysqli_exception_class_entry, sql_ex, "sqlstate", sizeof("sqlstate") - 1, - "00000" TSRMLS_CC); - } - - efree(message); - zend_update_property_long(mysqli_exception_class_entry, sql_ex, "code", sizeof("code") - 1, errorno TSRMLS_CC); - - zend_throw_exception_object(sql_ex TSRMLS_CC); -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_fe.c b/ext/mysqli/mysqli_fe.c deleted file mode 100644 index 9879cadb5c..0000000000 --- a/ext/mysqli/mysqli_fe.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - - -static - ZEND_BEGIN_ARG_INFO(second_arg_force_by_ref_rest, 1) - ZEND_ARG_PASS_INFO(0) - ZEND_END_ARG_INFO(); - -static - ZEND_BEGIN_ARG_INFO(third_arg_force_by_ref_rest, 1) - ZEND_ARG_PASS_INFO(0) - ZEND_ARG_PASS_INFO(0) - ZEND_END_ARG_INFO(); - -static - ZEND_BEGIN_ARG_INFO(all_args_force_by_ref, 1) - ZEND_END_ARG_INFO(); - - -/* {{{ mysqli_functions[] - * - * Every user visible function must have an entry in mysqli_functions[]. - */ -zend_function_entry mysqli_functions[] = { - PHP_FE(mysqli_affected_rows, NULL) - PHP_FE(mysqli_autocommit, NULL) - PHP_FE(mysqli_change_user, NULL) - PHP_FE(mysqli_character_set_name, NULL) - PHP_FE(mysqli_close, NULL) - PHP_FE(mysqli_commit, NULL) - PHP_FE(mysqli_connect, NULL) - PHP_FE(mysqli_connect_errno, NULL) - PHP_FE(mysqli_connect_error, NULL) - PHP_FE(mysqli_data_seek, NULL) - PHP_FE(mysqli_debug, NULL) - PHP_FE(mysqli_disable_reads_from_master, NULL) - PHP_FE(mysqli_disable_rpl_parse, NULL) - PHP_FE(mysqli_dump_debug_info, NULL) - PHP_FE(mysqli_enable_reads_from_master, NULL) - PHP_FE(mysqli_enable_rpl_parse, NULL) - PHP_FE(mysqli_embedded_server_end, NULL) - PHP_FE(mysqli_embedded_server_start, NULL) - PHP_FE(mysqli_errno, NULL) - PHP_FE(mysqli_error, 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) - PHP_FE(mysqli_fetch_lengths, NULL) - PHP_FE(mysqli_fetch_array, NULL) - PHP_FE(mysqli_fetch_assoc, NULL) - PHP_FE(mysqli_fetch_object, NULL) - PHP_FE(mysqli_fetch_row, NULL) - PHP_FE(mysqli_field_count, NULL) - PHP_FE(mysqli_field_seek, NULL) - PHP_FE(mysqli_field_tell, NULL) - PHP_FE(mysqli_free_result, NULL) -#ifdef HAVE_MYSQLI_GET_CHARSET - PHP_FE(mysqli_get_charset, NULL) -#endif - 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_proto_info, NULL) - PHP_FE(mysqli_get_server_info, NULL) - PHP_FE(mysqli_get_server_version, NULL) - PHP_FE(mysqli_get_warnings, NULL) - PHP_FE(mysqli_init, NULL) - PHP_FE(mysqli_info, NULL) - PHP_FE(mysqli_insert_id, NULL) - PHP_FE(mysqli_kill, NULL) - PHP_FE(mysqli_set_local_infile_default, NULL) - PHP_FE(mysqli_set_local_infile_handler, NULL) - PHP_FE(mysqli_master_query, NULL) - PHP_FE(mysqli_more_results, NULL) - PHP_FE(mysqli_multi_query, NULL) - PHP_FE(mysqli_next_result, NULL) - PHP_FE(mysqli_num_fields, NULL) - PHP_FE(mysqli_num_rows, NULL) - PHP_FE(mysqli_options, 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_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) -#ifdef HAVE_MYSQLI_SET_CHARSET - PHP_FE(mysqli_set_charset, NULL) -#endif - PHP_FE(mysqli_stmt_attr_get, NULL) - PHP_FE(mysqli_stmt_attr_set, NULL) - PHP_FE(mysqli_stmt_field_count, NULL) - PHP_FE(mysqli_stmt_init, NULL) - PHP_FE(mysqli_stmt_prepare, NULL) - 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_free_result, NULL) - PHP_FE(mysqli_stmt_get_warnings, NULL) - PHP_FE(mysqli_stmt_insert_id, NULL) - PHP_FE(mysqli_stmt_reset, NULL) - PHP_FE(mysqli_stmt_param_count, NULL) - PHP_FE(mysqli_send_query, NULL) - PHP_FE(mysqli_slave_query, NULL) - PHP_FE(mysqli_sqlstate, NULL) - PHP_FE(mysqli_ssl_set, NULL) - PHP_FE(mysqli_stat, NULL) - PHP_FE(mysqli_stmt_affected_rows, NULL) - PHP_FE(mysqli_stmt_close, NULL) - PHP_FE(mysqli_stmt_data_seek, NULL) - PHP_FE(mysqli_stmt_errno, NULL) - PHP_FE(mysqli_stmt_error, NULL) - PHP_FE(mysqli_stmt_num_rows, NULL) - PHP_FE(mysqli_stmt_sqlstate, NULL) - PHP_FE(mysqli_store_result, NULL) - PHP_FE(mysqli_stmt_store_result, NULL) - PHP_FE(mysqli_thread_id, NULL) - 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[] */ -}; -/* }}} */ - -/* {{{ mysqli_link_methods[] - * - * Every user visible function must have an entry in mysqli_functions[]. - */ -zend_function_entry mysqli_link_methods[] = { - PHP_FALIAS(autocommit,mysqli_autocommit,NULL) - PHP_FALIAS(change_user,mysqli_change_user,NULL) - PHP_FALIAS(character_set_name, mysqli_character_set_name,NULL) - PHP_FALIAS(client_encoding, mysqli_character_set_name,NULL) - PHP_FALIAS(close,mysqli_close,NULL) - PHP_FALIAS(commit,mysqli_commit,NULL) - PHP_FALIAS(connect,mysqli_connect,NULL) - PHP_FALIAS(debug,mysqli_debug,NULL) - PHP_FALIAS(disable_reads_from_master,mysqli_disable_reads_from_master,NULL) - PHP_FALIAS(disable_rpl_parse,mysqli_disable_rpl_parse,NULL) - PHP_FALIAS(dump_debug_info,mysqli_dump_debug_info,NULL) - PHP_FALIAS(enable_reads_from_master,mysqli_enable_reads_from_master,NULL) - PHP_FALIAS(enable_rpl_parse,mysqli_enable_rpl_parse,NULL) -#ifdef HAVE_MYSQLI_GET_CHARSET - PHP_FALIAS(get_charset,mysqli_get_charset,NULL) -#endif - PHP_FALIAS(get_client_info,mysqli_get_client_info,NULL) - PHP_FALIAS(get_server_info,mysqli_get_server_info,NULL) - PHP_FALIAS(get_warnings, mysqli_get_warnings, NULL) - PHP_FALIAS(init,mysqli_init,NULL) - PHP_FALIAS(kill,mysqli_kill,NULL) - PHP_FALIAS(set_local_infile_default,mysqli_set_local_infile_default,NULL) - PHP_FALIAS(set_local_infile_handler,mysqli_set_local_infile_handler,NULL) - PHP_FALIAS(master_query,mysqli_master_query,NULL) - PHP_FALIAS(multi_query,mysqli_multi_query,NULL) - PHP_FALIAS(mysqli,mysqli_connect,NULL) - PHP_FALIAS(more_results,mysqli_more_results, NULL) - PHP_FALIAS(next_result, mysqli_next_result, NULL) - PHP_FALIAS(options,mysqli_options,NULL) - PHP_FALIAS(ping,mysqli_ping,NULL) - PHP_FALIAS(prepare,mysqli_prepare,NULL) - PHP_FALIAS(query,mysqli_query,NULL) - PHP_FALIAS(real_connect,mysqli_real_connect,NULL) - PHP_FALIAS(real_escape_string,mysqli_real_escape_string,NULL) - PHP_FALIAS(escape_string, mysqli_real_escape_string,NULL) - PHP_FALIAS(real_query,mysqli_real_query,NULL) - PHP_FALIAS(rollback,mysqli_rollback,NULL) - PHP_FALIAS(rpl_parse_enabled,mysqli_rpl_parse_enabled,NULL) - PHP_FALIAS(rpl_probe,mysqli_rpl_probe,NULL) - PHP_FALIAS(rpl_query_type,mysqli_rpl_query_type,NULL) - PHP_FALIAS(select_db,mysqli_select_db,NULL) -#ifdef HAVE_MYSQLI_SET_CHARSET - PHP_FALIAS(set_charset,mysqli_set_charset,NULL) -#endif - PHP_FALIAS(set_opt, mysqli_options,NULL) - PHP_FALIAS(slave_query,mysqli_slave_query,NULL) - PHP_FALIAS(ssl_set,mysqli_ssl_set,NULL) - PHP_FALIAS(stat,mysqli_stat,NULL) - PHP_FALIAS(stmt_init,mysqli_stmt_init, NULL) - PHP_FALIAS(store_result,mysqli_store_result,NULL) - PHP_FALIAS(thread_safe,mysqli_thread_safe,NULL) - PHP_FALIAS(use_result,mysqli_use_result,NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -/* {{{ mysqli_result_methods[] - * - * Every user visible function must have an entry in mysqli_result_functions[]. - */ -zend_function_entry mysqli_result_methods[] = { - PHP_FALIAS(mysqli_result, mysqli_result_construct, NULL) - PHP_FALIAS(close,mysqli_free_result,NULL) - PHP_FALIAS(free,mysqli_free_result,NULL) - PHP_FALIAS(data_seek,mysqli_data_seek,NULL) - PHP_FALIAS(fetch_field,mysqli_fetch_field,NULL) - PHP_FALIAS(fetch_fields,mysqli_fetch_fields,NULL) - PHP_FALIAS(fetch_field_direct,mysqli_fetch_field_direct,NULL) - PHP_FALIAS(fetch_array,mysqli_fetch_array,NULL) - PHP_FALIAS(fetch_assoc,mysqli_fetch_assoc,NULL) - PHP_FALIAS(fetch_object,mysqli_fetch_object,NULL) - PHP_FALIAS(fetch_row,mysqli_fetch_row,NULL) - PHP_FALIAS(field_count,mysqli_field_count,NULL) - PHP_FALIAS(field_seek,mysqli_field_seek,NULL) - PHP_FALIAS(free_result,mysqli_free_result,NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -/* {{{ mysqli_stmt_methods[] - * - * Every user visible function must have an entry in mysqli_stmt_functions[]. - */ -zend_function_entry mysqli_stmt_methods[] = { - PHP_FALIAS(mysqli_stmt, mysqli_stmt_construct, NULL) - PHP_FALIAS(attr_get,mysqli_stmt_attr_get,NULL) - PHP_FALIAS(attr_set,mysqli_stmt_attr_set,NULL) - 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_stmt_execute,NULL) - PHP_FALIAS(fetch,mysqli_stmt_fetch,NULL) - PHP_FALIAS(get_warnings, mysqli_stmt_get_warnings, NULL) - PHP_FALIAS(result_metadata, mysqli_stmt_result_metadata,NULL) - PHP_FALIAS(num_rows, mysqli_stmt_num_rows,NULL) - PHP_FALIAS(send_long_data,mysqli_stmt_send_long_data,NULL) - PHP_FALIAS(stmt,mysqli_prepare,NULL) - PHP_FALIAS(free_result,mysqli_stmt_free_result,NULL) - PHP_FALIAS(reset,mysqli_stmt_reset,NULL) - PHP_FALIAS(prepare,mysqli_stmt_prepare, NULL) - PHP_FALIAS(store_result,mysqli_stmt_store_result,NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c deleted file mode 100644 index 4cc3f7bab2..0000000000 --- a/ext/mysqli/mysqli_nonapi.c +++ /dev/null @@ -1,376 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -/* {{{ proto object mysqli_connect([string hostname [,string username [,string passwd [,string dbname [,int port [,string socket]]]]]]) - Open a connection to a mysql server */ -PHP_FUNCTION(mysqli_connect) -{ - MY_MYSQL *mysql; - MYSQLI_RESOURCE *mysqli_resource; - zval *object = getThis(); - char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL; - unsigned int hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0; - long port=0; - - if (getThis() && !ZEND_NUM_ARGS()) { - RETURN_NULL(); - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssssls", &hostname, &hostname_len, &username, &username_len, - &passwd, &passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len) == FAILURE) { - return; - } - - if (!socket_len) { - socket = NULL; - } - - /* TODO: safe mode handling */ - if (PG(sql_safe_mode)){ - } else { - if (!passwd) { - passwd = MyG(default_pw); - if (!username){ - username = MyG(default_user); - if (!hostname) { - hostname = MyG(default_host); - } - } - } - } - - mysql = (MY_MYSQL *) ecalloc(1, sizeof(MY_MYSQL)); - - if (!(mysql->mysql = mysql_init(NULL))) { - efree(mysql); - RETURN_FALSE; - } - -#ifdef HAVE_EMBEDDED_MYSQLI - if (strcmp(hostname, ":embedded")) { - unsigned int external=1; - mysql_options(mysql->mysql, MYSQL_OPT_USE_REMOTE_CONNECTION, (char *)&external); - } else { - hostname[0] = '\0'; - mysql_options(mysql->mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, 0); - } -#endif - - if (!socket) { - socket = MyG(default_socket); - } - - if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,CLIENT_MULTI_RESULTS) == NULL) { - /* Save error messages */ - - php_mysqli_throw_sql_exception( mysql->mysql->net.sqlstate, mysql->mysql->net.last_errno TSRMLS_CC, - "%s", mysql->mysql->net.last_error); - - php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC); - - /* free mysql structure */ - mysql_close(mysql->mysql); - efree(mysql); - RETURN_FALSE; - } - - /* clear error */ - php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC); - - mysql->mysql->reconnect = MyG(reconnect); - - /* set our own local_infile handler */ - php_set_local_infile_handler_default(mysql); - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)mysql; - mysqli_resource->status = MYSQLI_STATUS_VALID; - - if (!object || !instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry TSRMLS_CC)) { - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); - } else { - ((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->ptr = mysqli_resource; - } -} -/* }}} */ - -/* {{{ proto int mysqli_connect_errno(void) - Returns the numerical value of the error message from last connect command */ -PHP_FUNCTION(mysqli_connect_errno) -{ - RETURN_LONG(MyG(error_no)); -} -/* }}} */ - -/* {{{ proto string mysqli_connect_error(void) - Returns the text of the error message from previous MySQL operation */ -PHP_FUNCTION(mysqli_connect_error) -{ - if (MyG(error_msg)) { - RETURN_STRING(MyG(error_msg),1); - } else { - RETURN_NULL(); - } -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_array (object result [,int resulttype]) - Fetch a result row as an associative array, a numeric array, or both */ -PHP_FUNCTION(mysqli_fetch_array) -{ - php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 0); -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_assoc (object result) - Fetch a result row as an associative array */ -PHP_FUNCTION(mysqli_fetch_assoc) -{ - php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 0); -} -/* }}} */ - -/* {{{ proto mixed mysqli_fetch_object (object result [, string class_name [, NULL|array ctor_params]]) - Fetch a result row as an object */ -PHP_FUNCTION(mysqli_fetch_object) -{ - php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 1); -} -/* }}} */ - -/* {{{ proto bool mysqli_multi_query(object link, string query) - Binary-safe version of mysql_query() */ -PHP_FUNCTION(mysqli_multi_query) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *query = NULL; - unsigned int query_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - MYSQLI_ENABLE_MQ; - if (mysql_real_query(mysql->mysql, query, query_len)) { - char s_error[MYSQL_ERRMSG_SIZE], s_sqlstate[SQLSTATE_LENGTH+1]; - unsigned int s_errno; - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - - /* we have to save error information, cause - MYSQLI_DISABLE_MQ will reset error information */ - strcpy(s_error, mysql_error(mysql->mysql)); - strcpy(s_sqlstate, mysql_sqlstate(mysql->mysql)); - s_errno = mysql_errno(mysql->mysql); - - MYSQLI_DISABLE_MQ; - - /* restore error information */ - strcpy(mysql->mysql->net.last_error, s_error); - strcpy(mysql->mysql->net.sqlstate, s_sqlstate); - mysql->mysql->net.last_errno = s_errno; - - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto mixed mysqli_query(object link, string query [,int resultmode]) */ -PHP_FUNCTION(mysqli_query) -{ - MY_MYSQL *mysql; - zval *mysql_link; - MYSQLI_RESOURCE *mysqli_resource; - MYSQL_RES *result; - char *query = NULL; - unsigned int query_len; - unsigned long resultmode = MYSQLI_STORE_RESULT; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) { - return; - } - - if (!query_len) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty query"); - RETURN_FALSE; - } - if (resultmode != MYSQLI_USE_RESULT && resultmode != MYSQLI_STORE_RESULT) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for resultmode"); - RETURN_FALSE; - } - - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - MYSQLI_DISABLE_MQ; - - if (mysql_real_query(mysql->mysql, query, query_len)) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - RETURN_FALSE; - } - - if (!mysql_field_count(mysql->mysql)) { - /* no result set - not a SELECT */ - if (MyG(report_mode) & MYSQLI_REPORT_INDEX) { - php_mysqli_report_index(query, mysql->mysql->server_status TSRMLS_CC); - } - RETURN_TRUE; - } - - result = (resultmode == MYSQLI_USE_RESULT) ? mysql_use_result(mysql->mysql) : mysql_store_result(mysql->mysql); - - if (!result) { - php_mysqli_throw_sql_exception(mysql->mysql->net.sqlstate, mysql->mysql->net.last_errno TSRMLS_CC, - "%s", mysql->mysql->net.last_error); - RETURN_FALSE; - } - - if (MyG(report_mode) & MYSQLI_REPORT_INDEX) { - php_mysqli_report_index(query, mysql->mysql->server_status TSRMLS_CC); - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)result; - mysqli_resource->status = MYSQLI_STATUS_VALID; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry); -} -/* }}} */ - -/* {{{ proto object mysqli_get_warnings(object link) */ -PHP_FUNCTION(mysqli_get_warnings) -{ - MY_MYSQL *mysql; - zval *mysql_link; - MYSQLI_RESOURCE *mysqli_resource; - MYSQLI_WARNING *w; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_warning_count(mysql->mysql)) { - w = php_get_warnings(mysql->mysql); - } else { - RETURN_FALSE; - } - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = mysqli_resource->info = (void *)w; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); -} -/* }}} */ - -/* {{{ proto object mysqli_stmt_get_warnings(object link) */ -PHP_FUNCTION(mysqli_stmt_get_warnings) -{ - MY_STMT *stmt; - zval *stmt_link; - MYSQLI_RESOURCE *mysqli_resource; - MYSQLI_WARNING *w; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &stmt_link, mysqli_stmt_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT*, &stmt_link, "mysqli_stmt", 1); - - if (mysql_warning_count(stmt->stmt->mysql)) { - w = php_get_warnings(stmt->stmt->mysql); - } else { - RETURN_FALSE; - } - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = mysqli_resource->info = (void *)w; - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); -} -/* }}} */ - -#ifdef HAVE_MYSQLI_SET_CHARSET -/* {{{ proto bool mysqli_set_charset(object link, string csname) - sets client character set */ -PHP_FUNCTION(mysqli_set_charset) -{ - MY_MYSQL *mysql; - zval *mysql_link; - char *cs_name = NULL; - unsigned int len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_set_character_set(mysql->mysql, cs_name)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ -#endif - -#ifdef HAVE_MYSQLI_GET_CHARSET -/* {{{ proto object mysqli_get_charset(object link) - returns a character set object */ -PHP_FUNCTION(mysqli_get_charset) -{ - MY_MYSQL *mysql; - zval *mysql_link; - MY_CHARSET_INFO cs; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - object_init(return_value); - - mysql_get_character_set_info(mysql->mysql, &cs); - - add_property_string(return_value, "charset", (cs.name) ? (char *)cs.csname : "", 1); - add_property_string(return_value, "collation",(cs.name) ? (char *)cs.name : "", 1); - add_property_string(return_value, "comment", (cs.comment) ? (char *)cs.comment : "", 1); - add_property_string(return_value, "dir", (cs.dir) ? (char *)cs.dir : "", 1); - add_property_long(return_value, "min_length", cs.mbminlen); - add_property_long(return_value, "max_length", cs.mbmaxlen); - add_property_long(return_value, "number", cs.number); - add_property_long(return_value, "state", cs.state); -} -/* }}} */ -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c deleted file mode 100644 index db7b637728..0000000000 --- a/ext/mysqli/mysqli_prop.c +++ /dev/null @@ -1,365 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -#define CHECK_STATUS(value) \ - if (((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property access is not allowed yet"); \ - ZVAL_NULL(*retval); \ - return SUCCESS; \ - } \ - -#define MYSQLI_GET_MYSQL(statusval) \ -MYSQL *p; \ -ALLOC_ZVAL(*retval);\ -if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\ - ZVAL_NULL(*retval);\ - return SUCCESS; \ -} else { \ - CHECK_STATUS(statusval);\ - p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql;\ -} - -#define MYSQLI_GET_RESULT(statusval) \ -MYSQL_RES *p; \ -ALLOC_ZVAL(*retval);\ -if (!obj->ptr) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\ - ZVAL_NULL(*retval);\ - return SUCCESS; \ -} else { \ - CHECK_STATUS(statusval);\ - p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; \ -} - - -#define MYSQLI_GET_STMT(statusval) \ -MYSQL_STMT *p; \ -ALLOC_ZVAL(*retval);\ -if (!obj->ptr) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\ - ZVAL_NULL(*retval);\ - return SUCCESS; \ -} else { \ - CHECK_STATUS(statusval);\ - p = (MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt;\ -} - -#define MYSQLI_MAP_PROPERTY_FUNC_LONG( __func, __int_func, __get_type, __ret_type)\ -static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \ -{\ - __ret_type l;\ - __get_type;\ - if (!p) {\ - ZVAL_NULL(*retval);\ - } else {\ - l = (__ret_type)__int_func(p);\ - if (l < LONG_MAX) {\ - ZVAL_LONG(*retval, l);\ - } else { \ - char ret[40]; \ - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong)l); \ - ZVAL_STRING(*retval, ret, 1); \ - } \ - }\ - return SUCCESS;\ -} - -#define MYSQLI_MAP_PROPERTY_FUNC_STRING(__func, __int_func, __get_type)\ -static int __func(mysqli_object *obj, zval **retval TSRMLS_DC)\ -{\ - char *c;\ - __get_type;\ - if (!p) {\ - ZVAL_NULL(*retval);\ - } else {\ - c = (char *)__int_func(p);\ - if (!c) {\ - ZVAL_NULL(*retval);\ - } else {\ - ZVAL_STRING(*retval, c, 1);\ - }\ - }\ - return SUCCESS;\ -} - -/* {{{ property link_client_version_read */ -static int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - ZVAL_LONG(*retval, MYSQL_VERSION_ID); - return SUCCESS; -} -/* }}} */ - -/* {{{ property link_client_info_read */ -static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - CHECK_STATUS(MYSQLI_STATUS_INITIALIZED); - ZVAL_STRING(*retval, MYSQL_SERVER_VERSION, 1); - return SUCCESS; -} -/* }}} */ - -/* {{{ property link_connect_errno_read */ -static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - CHECK_STATUS(MYSQLI_STATUS_INITIALIZED); - ZVAL_LONG(*retval, (long)MyG(error_no)); - return SUCCESS; -} -/* }}} */ - -/* {{{ property link_connect_error_read */ -static int link_connect_error_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - ALLOC_ZVAL(*retval); - CHECK_STATUS(MYSQLI_STATUS_INITIALIZED); - ZVAL_STRING(*retval, MyG(error_msg), 1); - return SUCCESS; -} -/* }}} */ - -/* {{{ property link_affected_rows_read */ -static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MY_MYSQL *mysql; - my_ulonglong rc; - - ALLOC_ZVAL(*retval); - - mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - - if (!mysql) { - ZVAL_NULL(*retval); - } else { - CHECK_STATUS(MYSQLI_STATUS_VALID); - - rc = mysql_affected_rows(mysql->mysql); - - if (rc == (my_ulonglong)-1) { - ZVAL_LONG(*retval, -1); - return SUCCESS; - } - - if (rc < LONG_MAX) { - ZVAL_LONG(*retval, rc); - } else { - char ret[40]; - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); - ZVAL_STRING(*retval, ret, 1); - } - } - return SUCCESS; -} -/* }}} */ - -/* link properties */ -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_errno_read, mysql_errno, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED), ulong); -MYSQLI_MAP_PROPERTY_FUNC_STRING(link_error_read, mysql_error, MYSQLI_GET_MYSQL(MYSQLI_STATUS_INITIALIZED)); -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_STRING(link_host_info_read, mysql_get_host_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID)); -MYSQLI_MAP_PROPERTY_FUNC_STRING(link_info_read, mysql_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID)); -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_insert_id_read, mysql_insert_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), my_ulonglong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_STRING(link_server_info_read, mysql_get_server_info, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID)); -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID)); -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong); -/* result properties */ - -/* {{{ property result_type_read */ -static int result_type_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MYSQL_RES *p; - - ALLOC_ZVAL(*retval); - CHECK_STATUS(MYSQLI_STATUS_VALID); - p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - - if (!p) { - ZVAL_NULL(*retval); - } else { - ZVAL_LONG(*retval, (p->data) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ property result_lengths_read */ -static int result_lengths_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MYSQL_RES *p; - - ALLOC_ZVAL(*retval); - - CHECK_STATUS(MYSQLI_STATUS_VALID); - p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - if (!p || !p->field_count) { - ZVAL_NULL(*retval); - } else { - ulong i; - zval *l; - - array_init(*retval); - - for (i=0; i < p->field_count; i++) { - MAKE_STD_ZVAL(l); - ZVAL_LONG(l, p->lengths[i]); - add_index_zval(*retval, i, l); - } - } - return SUCCESS; -} -/* }}} */ - - -MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(result_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(MYSQLI_STATUS_VALID), my_ulonglong); - -/* statement properties */ - -/* {{{ property stmt_id_read */ -static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MY_STMT *p; - - ALLOC_ZVAL(*retval); - CHECK_STATUS(MYSQLI_STATUS_VALID); - - p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - - if (!p) { - ZVAL_NULL(*retval); - } else { - ZVAL_LONG(*retval, p->stmt->stmt_id); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ property stmt_affected_rows_read */ -static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MY_STMT *p; - my_ulonglong rc; - - ALLOC_ZVAL(*retval); - CHECK_STATUS(MYSQLI_STATUS_VALID); - - p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - - if (!p) { - ZVAL_NULL(*retval); - } else { - rc = mysql_stmt_affected_rows(p->stmt); - - if (rc == (my_ulonglong)-1) { - ZVAL_LONG(*retval, -1); - return SUCCESS; - } - - if (rc < LONG_MAX) { - ZVAL_LONG(*retval, rc); - } else { - char ret[40]; - sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); - ZVAL_STRING(*retval, ret, 1); - } - } - return SUCCESS; -} -/* }}} */ - -MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_insert_id_read, mysql_stmt_insert_id, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_num_rows_read, mysql_stmt_num_rows, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), my_ulonglong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(MYSQLI_STATUS_VALID), ulong); -MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED), ulong); -MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_error_read, mysql_stmt_error, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED)); -MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_GET_STMT(MYSQLI_STATUS_INITIALIZED)); - -/* }}} */ -mysqli_property_entry mysqli_link_property_entries[] = { - {"affected_rows", link_affected_rows_read, NULL}, - {"client_info", link_client_info_read, NULL}, - {"client_version", link_client_version_read, NULL}, - {"connect_errno", link_connect_errno_read, NULL}, - {"connect_error", link_connect_error_read, NULL}, - {"errno", link_errno_read, NULL}, - {"error", link_error_read, NULL}, - {"field_count", link_field_count_read, NULL}, - {"host_info", link_host_info_read, NULL}, - {"info", link_info_read, NULL}, - {"insert_id", link_insert_id_read, NULL}, - {"server_info", link_server_info_read, NULL}, - {"server_version", link_server_version_read, NULL}, - {"sqlstate", link_sqlstate_read, NULL}, - {"protocol_version", link_protocol_version_read, NULL}, - {"thread_id", link_thread_id_read, NULL}, - {"warning_count", link_warning_count_read, NULL}, - {NULL, NULL, NULL} -}; - -mysqli_property_entry mysqli_result_property_entries[] = { - {"current_field", result_current_field_read, NULL}, - {"field_count", result_field_count_read, NULL}, - {"lengths", result_lengths_read, NULL}, - {"num_rows", result_num_rows_read, NULL}, - {"type", result_type_read, NULL}, - {NULL, NULL, NULL} -}; - -mysqli_property_entry mysqli_stmt_property_entries[] = { - {"affected_rows", stmt_affected_rows_read, NULL}, - {"insert_id", stmt_insert_id_read, NULL}, - {"num_rows", stmt_num_rows_read, NULL}, - {"param_count", stmt_param_count_read, NULL}, - {"field_count", stmt_field_count_read, NULL}, - {"errno", stmt_errno_read, NULL}, - {"error", stmt_error_read, NULL}, - {"sqlstate", stmt_sqlstate_read, NULL}, - {"id", stmt_id_read, NULL}, - {NULL, NULL, NULL} -}; - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_repl.c b/ext/mysqli/mysqli_repl.c deleted file mode 100644 index b68c4509b0..0000000000 --- a/ext/mysqli/mysqli_repl.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -/* {{{ proto void mysqli_disable_reads_from_master(object link) -*/ -PHP_FUNCTION(mysqli_disable_reads_from_master) -{ - MYSQL *mysql; - zval *mysql_link; - - 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", MYSQLI_STATUS_VALID); - mysql_disable_reads_from_master(mysql); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_disable_rpl_parse(object link) -*/ -PHP_FUNCTION(mysqli_disable_rpl_parse) -{ - MYSQL *mysql; - zval *mysql_link; - - 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", MYSQLI_STATUS_VALID); - mysql_disable_rpl_parse(mysql); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_enable_reads_from_master(object link) -*/ -PHP_FUNCTION(mysqli_enable_reads_from_master) -{ - MYSQL *mysql; - zval *mysql_link; - - 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", MYSQLI_STATUS_VALID); - - mysql_enable_reads_from_master(mysql); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_enable_rpl_parse(object link) -*/ -PHP_FUNCTION(mysqli_enable_rpl_parse) -{ - MYSQL *mysql; - zval *mysql_link; - - 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", MYSQLI_STATUS_VALID); - - mysql_enable_rpl_parse(mysql); - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_master_query(object link, string query) - Enforce execution of a query on the master in a master/slave setup */ -PHP_FUNCTION(mysqli_master_query) { - MYSQL *mysql; - zval *mysql_link; - char *query = NULL; - unsigned int query_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_master_query(mysql, query, query_len)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int mysqli_rpl_parse_enabled(object link) -*/ -PHP_FUNCTION(mysqli_rpl_parse_enabled) -{ - MYSQL *mysql; - zval *mysql_link; - - 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", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_rpl_parse_enabled(mysql)); -} -/* }}} */ - -/* {{{ proto bool mysqli_rpl_probe(object link) -*/ -PHP_FUNCTION(mysqli_rpl_probe) -{ - MYSQL *mysql; - zval *mysql_link; - - 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", MYSQLI_STATUS_VALID); - - - if (mysql_rpl_probe(mysql)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto int mysqli_rpl_query_type(string query) -*/ -PHP_FUNCTION(mysqli_rpl_query_type) -{ - MYSQL *mysql; - zval *mysql_link; - char *query; - int query_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - RETURN_LONG(mysql_rpl_query_type(query, query_len)); -} -/* }}} */ - -/* {{{ proto bool mysqli_send_query(object link, string query) -*/ -PHP_FUNCTION(mysqli_send_query) -{ - MYSQL *mysql; - zval *mysql_link; - char *query = NULL; - unsigned int query_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_send_query(mysql, query, query_len)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto bool mysqli_slave_query(object link, string query) - Enforce execution of a query on a slave in a master/slave setup */ -PHP_FUNCTION(mysqli_slave_query) -{ - MYSQL *mysql; - zval *mysql_link; - char *query = NULL; - unsigned int query_len; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) { - return; - } - MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID); - - if (mysql_slave_query(mysql, query, query_len)) { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_report.c b/ext/mysqli/mysqli_report.c deleted file mode 100644 index a6e466c091..0000000000 --- a/ext/mysqli/mysqli_report.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -/* {{{ proto bool mysqli_report(int flags) - sets report level */ -PHP_FUNCTION(mysqli_report) -{ - long flags; - - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) { - return; - } - - MyG(report_mode) = flags; - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ void php_mysqli_report_error(char *sqlstate, int errorno, char *error) */ -void php_mysqli_report_error(char *sqlstate, int errorno, char *error TSRMLS_DC) { - php_mysqli_throw_sql_exception(sqlstate, errorno TSRMLS_CC, "%s", error); -} -/* }}} */ - -/* {{{ void php_mysqli_report_index() */ -void php_mysqli_report_index(char *query, unsigned int status TSRMLS_DC) { - char index[15]; - - if (status & SERVER_QUERY_NO_GOOD_INDEX_USED) { - strcpy(index, "Bad index"); - } else if (status & SERVER_QUERY_NO_INDEX_USED) { - strcpy(index, "No index"); - } else { - return; - } - php_mysqli_throw_sql_exception("00000", 0 TSRMLS_CC, "%s used in query/prepared statement %s", index, query); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_report.h b/ext/mysqli/mysqli_report.h deleted file mode 100644 index bcb365c992..0000000000 --- a/ext/mysqli/mysqli_report.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -#ifndef __HAVE_MYSQLI_PROFILER_H__ -#define __HAVE_MYSQLI_PROFILER_H__ - -#ifdef PHP_WIN32 -#include <process.h> -#include <direct.h> -#include "win32/time.h" -#else -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include <sys/time.h> -#endif - -typedef struct { - struct timeval starttime, - endtime; /* execution time */ -} PR_TIME_INFO; - - -#define MYSQLI_PR_REPORT_STDERR 1 -#define MYSQLI_PR_REPORT_PORT 2 - - - -/*** PROFILER MACROS ***/ -#define MYSQLI_PROFILER_STARTTIME(ptr) if (MyG(profiler.mode)) gettimeofday(&ptr.starttime, NULL) -#define MYSQLI_PROFILER_ENDTIME(ptr) if (MyG(profiler.mode)) gettimeofday(&ptr.endtime, NULL) -#define MYSQLI_PROFILER_REPORT(_type, _time, ptr) if (MyG(profiler.mode)) php_mysqli_profiler_report(_type, _time, (void *)ptr) - - - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c deleted file mode 100644 index 733eab149a..0000000000 --- a/ext/mysqli/mysqli_warning.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - -*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <signal.h> - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_mysqli.h" - -/* {{{ void php_clear_warnings() */ -void php_clear_warnings(MYSQLI_WARNING *w) -{ - MYSQLI_WARNING *n; - - while (w) { - n = w; - efree(w->reason); - w = w->next; - efree(n); - } -} -/* }}} */ - -/* {{{ MYSQLI_WARNING *php_new_warning */ -MYSQLI_WARNING *php_new_warning(char *reason, char *sqlstate, int errorno) -{ - MYSQLI_WARNING *w; - - w = (MYSQLI_WARNING *)ecalloc(1, sizeof(MYSQLI_WARNING)); - - w->reason = safe_estrdup(reason); - if (sqlstate) { - strcpy(w->sqlstate, sqlstate); - } else { - strcpy(w->sqlstate, "00000"); - } - w->errorno = errorno; - - return w; -} -/* }}} */ - -/* {{{ MYSQLI_WARNING *php_get_warnings(MYSQL *mysql) */ -MYSQLI_WARNING *php_get_warnings(MYSQL *mysql) -{ - MYSQLI_WARNING *w, *first = NULL, *prev = NULL; - MYSQL_RES *result; - MYSQL_ROW row; - - if (mysql_query(mysql, "SHOW WARNINGS")) { - return NULL; - } - - result = mysql_store_result(mysql); - while ((row = mysql_fetch_row(result))) { - w = php_new_warning(row[2], "HY000", atoi(row[1])); - if (!first) { - first = w; - } - if (prev) { - prev->next = (void *)w; - } - prev = w; - } - mysql_free_result(result); - return first; -} -/* }}} */ - -/* {{{ bool mysqli_warning::next() */ -PHP_METHOD(mysqli_warning, next) -{ - MYSQLI_WARNING *w; - zval *mysqli_warning; - mysqli_object *obj = (mysqli_object *)zend_objects_get_address(getThis() TSRMLS_CC); - - if (obj->ptr) { - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", - &mysqli_warning, mysqli_warning_class_entry) == FAILURE) { - return; - } - - MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysqli_warning, "mysqli_warning", MYSQLI_STATUS_VALID); - - if (w->next) { - w = w->next; - ((MYSQLI_RESOURCE *)(obj->ptr))->ptr = w; - RETURN_TRUE; - } - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ property mysqli_warning_message */ -int mysqli_warning_message(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MYSQLI_WARNING *w; - - if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { - return FAILURE; - } - - w = (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - ALLOC_ZVAL(*retval); - if (w->reason) { - ZVAL_STRING(*retval, w->reason, 1); - } else { - ZVAL_NULL(*retval); - } - return SUCCESS; -} -/* }}} */ - -/* {{{ property mysqli_warning_sqlstate */ -int mysqli_warning_sqlstate(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MYSQLI_WARNING *w; - - if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { - return FAILURE; - } - - w = (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - ALLOC_ZVAL(*retval); - ZVAL_STRING(*retval, w->sqlstate, 1); - return SUCCESS; -} -/* }}} */ - -/* {{{ property mysqli_warning_error */ -int mysqli_warning_errno(mysqli_object *obj, zval **retval TSRMLS_DC) -{ - MYSQLI_WARNING *w; - - if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { - return FAILURE; - } - w = (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr; - ALLOC_ZVAL(*retval); - ZVAL_LONG(*retval, w->errorno); - return SUCCESS; -} -/* }}} */ - -/* {{{ mysqli_warning_construct(object obj) */ -PHP_METHOD(mysqli_warning, __construct) -{ - zval *z; - mysqli_object *obj; - MYSQL *hdl; - MYSQLI_WARNING *w; - MYSQLI_RESOURCE *mysqli_resource; - - if (ZEND_NUM_ARGS() != 1) { - WRONG_PARAM_COUNT; - } - if (zend_parse_parameters(1 TSRMLS_CC, "o", &z)==FAILURE) { - return; - } - obj = (mysqli_object *)zend_object_store_get_object(z TSRMLS_CC);\ - - if (obj->zo.ce == mysqli_link_class_entry) { - MY_MYSQL *mysql; - MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &z, "mysqli_link", MYSQLI_STATUS_VALID); - hdl = mysql->mysql; - } else if (obj->zo.ce == mysqli_stmt_class_entry) { - MY_STMT *stmt; - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &z, "mysqli_stmt", MYSQLI_STATUS_VALID); - hdl = stmt->stmt->mysql; - } else { - RETURN_FALSE; - } - - if (mysql_warning_count(hdl)) { - w = php_get_warnings(hdl); - } else { - RETURN_FALSE; - } - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->status = MYSQLI_STATUS_VALID; - mysqli_resource->ptr = mysqli_resource->info = (void *)w; - - if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_warning_class_entry TSRMLS_CC)) { - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); - } else { - ((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource; - } - -} -/* }}} */ - -zend_function_entry mysqli_warning_methods[] = { - PHP_ME(mysqli_warning, __construct, NULL, ZEND_ACC_PROTECTED) - PHP_ME(mysqli_warning, next, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} -}; - -mysqli_property_entry mysqli_warning_property_entries[] = { - {"message", mysqli_warning_message, NULL}, - {"sqlstate", mysqli_warning_sqlstate, NULL}, - {"errno", mysqli_warning_errno, NULL}, - {NULL, NULL, NULL} -}; - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/package.xml b/ext/mysqli/package.xml deleted file mode 100644 index 1487256d27..0000000000 --- a/ext/mysqli/package.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "../pear/package.dtd"> -<package> - <name>mysqli</name> - <summary>MySQLi - new MySQL interface for PHP 5 and MySQL 4.1+</summary> - <maintainers> - <maintainer> - <user>georg</user> - <name>Georg Richter</name> - <email>georg@php.net</email> - <role>lead</role> - </maintainer> - <maintainer> - <user>zak</user> - <name>Zak Greant</name> - <email>zak@php.net</email> - <role>lead</role> - </maintainer> - </maintainers> - <description> -MySQLi is a rewrite of the original MySQL extension ... - </description> - <license>PHP</license> - <release> - <state>beta</state> - <version>5.0.0rc1</version> - <date>2004-03-19</date> - <notes> -package.xml added to support intallation using pear installer - </notes> - <configureoptions> - <configureoption name="with-mysqli" default="autodetect" prompt="path to mysql_config tool?"/> - <configureoption name="enable-embedded-mysqli" default="no" prompt="embedd mysql server into PHP?"/> - </configureoptions> - <filelist> - <file role="src" name="config.m4"/> - <file role="src" name="config.w32"/> - <file role="src" name="mysqli.dsp"/> - <file role="src" name="mysqli.c"/> - <file role="src" name="mysqli_api.c"/> - <file role="src" name="mysqli_fe.c"/> - <file role="src" name="mysqli_nonapi.c"/> - <file role="src" name="mysqli_prop.c"/> - <file role="src" name="mysqli_repl.c"/> - <file role="src" name="mysqli_report.c"/> - <file role="src" name="mysqli_report.h"/> - <file role="src" name="php_mysqli.h"/> - <file role="doc" name="CREDITS"/> - <file role="test" name="tests/001.phpt"/> - <file role="test" name="tests/002.phpt"/> - <file role="test" name="tests/003.phpt"/> - <file role="test" name="tests/004.phpt"/> - <file role="test" name="tests/005.phpt"/> - <file role="test" name="tests/006.phpt"/> - <file role="test" name="tests/007.phpt"/> - <file role="test" name="tests/008.phpt"/> - <file role="test" name="tests/009.phpt"/> - <file role="test" name="tests/010.phpt"/> - <file role="test" name="tests/011.phpt"/> - <file role="test" name="tests/012.phpt"/> - <file role="test" name="tests/013.phpt"/> - <file role="test" name="tests/014.phpt"/> - <file role="test" name="tests/015.phpt"/> - <file role="test" name="tests/016.phpt"/> - <file role="test" name="tests/017.phpt"/> - <file role="test" name="tests/018.phpt"/> - <file role="test" name="tests/019.phpt"/> - <file role="test" name="tests/020.phpt"/> - <file role="test" name="tests/021.phpt"/> - <file role="test" name="tests/022.phpt"/> - <file role="test" name="tests/023.phpt"/> - <file role="test" name="tests/024.phpt"/> - <file role="test" name="tests/025.phpt"/> - <file role="test" name="tests/026.phpt"/> - <file role="test" name="tests/027.phpt"/> - <file role="test" name="tests/028.phpt"/> - <file role="test" name="tests/029.phpt"/> - <file role="test" name="tests/030.phpt"/> - <file role="test" name="tests/031.phpt"/> - <file role="test" name="tests/032.phpt"/> - <file role="test" name="tests/033.phpt"/> - <file role="test" name="tests/034.phpt"/> - <file role="test" name="tests/035.phpt"/> - <file role="test" name="tests/036.phpt"/> - <file role="test" name="tests/037.phpt"/> - <file role="test" name="tests/038.phpt"/> - <file role="test" name="tests/039.phpt"/> - <file role="test" name="tests/040.phpt"/> - <file role="test" name="tests/041.phpt"/> - <file role="test" name="tests/042.phpt"/> - <file role="test" name="tests/043.phpt"/> - <file role="test" name="tests/044.phpt"/> - <file role="test" name="tests/045.phpt"/> - <file role="test" name="tests/046.phpt"/> - <file role="test" name="tests/047.phpt"/> - <file role="test" name="tests/048.phpt"/> - <file role="test" name="tests/049.phpt"/> - <file role="test" name="tests/050.phpt"/> - <file role="test" name="tests/051.phpt"/> - <file role="test" name="tests/052.phpt"/> - <file role="test" name="tests/053.phpt"/> - <file role="test" name="tests/054.phpt"/> - <file role="test" name="tests/055.phpt"/> - <file role="test" name="tests/056.phpt"/> - <file role="test" name="tests/057.phpt"/> - <file role="test" name="tests/058.phpt"/> - <file role="test" name="tests/059.phpt"/> - <file role="test" name="tests/060.phpt"/> - <file role="test" name="tests/connect.inc"/> - </filelist> - <deps> - <dep type="php" rel="ge" version="5" /> - </deps> - </release> -</package> -<!-- -vim:et:ts=1:sw=1 ---> diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h deleted file mode 100644 index 355403d84b..0000000000 --- a/ext/mysqli/php_mysqli.h +++ /dev/null @@ -1,482 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2006 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Georg Richter <georg@php.net> | - +----------------------------------------------------------------------+ - - $Id$ -*/ - -/* A little hack to prevent build break, when mysql is used together with - * c-client, which also defines LIST. - */ -#ifdef LIST -#undef LIST -#endif - -#include <mysql.h> - -/* character set support */ -#if MYSQL_VERSION_ID > 50009 -#define HAVE_MYSQLI_GET_CHARSET -#endif - -#if (MYSQL_VERSION_ID > 40112 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID > 50005 -#define HAVE_MYSQLI_SET_CHARSET -#endif - - -#include <errmsg.h> - -#ifndef PHP_MYSQLI_H -#define PHP_MYSQLI_H - -#define MYSQLI_VERSION_ID 101009 - -enum mysqli_status { - MYSQLI_STATUS_UNKNOWN=0, - MYSQLI_STATUS_CLEARED, - MYSQLI_STATUS_INITIALIZED, - MYSQLI_STATUS_VALID -}; - -typedef struct { - ulong buflen; - char *val; - ulong type; -} VAR_BUFFER; - -typedef struct { - unsigned int var_cnt; - VAR_BUFFER *buf; - zval **vars; - char *is_null; -} BIND_BUFFER; - -typedef struct { - MYSQL_STMT *stmt; - BIND_BUFFER param; - BIND_BUFFER result; - char *query; -} MY_STMT; - -typedef struct { - MYSQL *mysql; - zval *li_read; - php_stream *li_stream; - unsigned int multi_query; -} MY_MYSQL; - -typedef struct { - int mode; - int socket; - FILE *fp; -} PROFILER; - -typedef struct { - void *ptr; /* resource: (mysql, result, stmt) */ - void *info; /* additional buffer */ - enum mysqli_status status; -} MYSQLI_RESOURCE; - -typedef struct _mysqli_object { - zend_object zo; - void *ptr; - HashTable *prop_handler; -} mysqli_object; /* extends zend_object */ - -typedef struct { - char *reason; - char sqlstate[6]; - int errorno; - void *next; -} MYSQLI_WARNING; - -typedef struct _mysqli_property_entry { - char *pname; - int (*r_func)(mysqli_object *obj, zval **retval TSRMLS_DC); - int (*w_func)(mysqli_object *obj, zval *value TSRMLS_DC); -} mysqli_property_entry; - -typedef struct { - char error_msg[LOCAL_INFILE_ERROR_LEN]; - void *userdata; -} mysqli_local_infile; - -#define phpext_mysqli_ptr &mysqli_module_entry - -#ifdef PHP_WIN32 -#define PHP_MYSQLI_API __declspec(dllexport) -#define MYSQLI_LLU_SPEC "%I64u" -#define MYSQLI_LL_SPEC "%I64d" -#else -#define PHP_MYSQLI_API -#define MYSQLI_LLU_SPEC "%llu" -#define MYSQLI_LL_SPEC "%lld" -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type - -extern zend_module_entry mysqli_module_entry; -extern zend_function_entry mysqli_functions[]; -extern zend_function_entry mysqli_link_methods[]; -extern zend_function_entry mysqli_stmt_methods[]; -extern zend_function_entry mysqli_result_methods[]; -extern zend_function_entry mysqli_driver_methods[]; -extern zend_function_entry mysqli_warning_methods[]; -extern zend_function_entry mysqli_exception_methods[]; - -extern mysqli_property_entry mysqli_link_property_entries[]; -extern mysqli_property_entry mysqli_result_property_entries[]; -extern mysqli_property_entry mysqli_stmt_property_entries[]; -extern mysqli_property_entry mysqli_driver_property_entries[]; -extern mysqli_property_entry mysqli_warning_property_entries[]; - -extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flag, int into_object); -extern void php_clear_stmt_bind(MY_STMT *stmt); -extern void php_clear_mysql(MY_MYSQL *); -extern MYSQLI_WARNING *php_get_warnings(MYSQL *mysql); -extern void php_clear_warnings(MYSQLI_WARNING *w); -extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type); -extern void php_mysqli_report_error(char *sqlstate, int errorno, char *error TSRMLS_DC); -extern void php_mysqli_report_index(char *query, unsigned int status TSRMLS_DC); -extern int php_local_infile_init(void **, const char *, void *); -extern int php_local_infile_read(void *, char *, uint); -extern void php_local_infile_end(void *); -extern int php_local_infile_error(void *, char *, uint); -extern void php_set_local_infile_handler_default(MY_MYSQL *); -extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...); -extern zend_class_entry *mysqli_link_class_entry; -extern zend_class_entry *mysqli_stmt_class_entry; -extern zend_class_entry *mysqli_result_class_entry; -extern zend_class_entry *mysqli_driver_class_entry; -extern zend_class_entry *mysqli_warning_class_entry; -extern zend_class_entry *mysqli_exception_class_entry; - -#ifdef HAVE_SPL -extern PHPAPI zend_class_entry *spl_ce_RuntimeException; -#endif - -PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC); - -#define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \ - mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \ - mysql->multi_query = 0; \ -} - -#define MYSQLI_ENABLE_MQ if (!mysql->multi_query) { \ - mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON); \ - mysql->multi_query = 1; \ -} - -#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \ - zend_class_entry ce; \ - INIT_CLASS_ENTRY(ce, name,class_functions); \ - ce.create_object = mysqli_objects_new; \ - mysqli_entry = zend_register_internal_class(&ce TSRMLS_CC); \ -} \ - -#define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval) \ - ((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->ptr = __ptr; \ - -#define MYSQLI_RETURN_RESOURCE(__ptr, __ce) \ - Z_TYPE_P(return_value) = IS_OBJECT; \ - (return_value)->value.obj = mysqli_objects_new(__ce TSRMLS_CC); \ - MYSQLI_REGISTER_RESOURCE_EX(__ptr, return_value) - -#define MYSQLI_REGISTER_RESOURCE(__ptr, __ce) \ -{\ - zval *object = getThis();\ - if (!object || !instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry TSRMLS_CC)) {\ - object = return_value;\ - Z_TYPE_P(object) = IS_OBJECT;\ - (object)->value.obj = mysqli_objects_new(__ce TSRMLS_CC);\ - }\ - MYSQLI_REGISTER_RESOURCE_EX(__ptr, object)\ -} - -#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name, __check) \ -{ \ - MYSQLI_RESOURCE *my_res; \ - mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\ - if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {\ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);\ - RETURN_NULL();\ - }\ - __ptr = (__type)my_res->ptr; \ - if (__check && my_res->status < __check) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name); \ - RETURN_NULL();\ - }\ -} - -#define MYSQLI_SET_STATUS(__id, __value) \ -{ \ - mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\ - ((MYSQLI_RESOURCE *)intern->ptr)->status = __value; \ -} \ - -#define MYSQLI_CLEAR_RESOURCE(__id) \ -{ \ - mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\ - efree(intern->ptr); \ - intern->ptr = NULL; \ -} - -#define MYSQLI_RETURN_LONG_LONG(__val) \ -{ \ - if ((__val) < LONG_MAX) { \ - RETURN_LONG((__val)); \ - } else { \ - char ret[40]; \ - sprintf(ret, "%llu", (__val)); \ - RETURN_STRING(ret,1); \ - } \ -} - -#define MYSQLI_ADD_PROPERTIES(a,b) \ -{ \ - int i = 0; \ - while (b[i].pname != NULL) { \ - mysqli_add_property(a, b[i].pname, (mysqli_read_t)b[i].r_func, (mysqli_write_t)b[i].w_func TSRMLS_CC); \ - i++; \ - }\ -} - -#if WIN32|WINNT -#define SCLOSE(a) closesocket(a) -#else -#define SCLOSE(a) close(a) -#endif - -#define MYSQLI_STORE_RESULT 0 -#define MYSQLI_USE_RESULT 1 - -/* for mysqli_fetch_assoc */ -#define MYSQLI_ASSOC 1 -#define MYSQLI_NUM 2 -#define MYSQLI_BOTH 3 - -/* for mysqli_bind_param */ -#define MYSQLI_BIND_INT 1 -#define MYSQLI_BIND_DOUBLE 2 -#define MYSQLI_BIND_STRING 3 -#define MYSQLI_BIND_SEND_DATA 4 - -/* fetch types */ -#define FETCH_SIMPLE 1 -#define FETCH_RESULT 2 - -/*** REPORT MODES ***/ -#define MYSQLI_REPORT_OFF 0 -#define MYSQLI_REPORT_ERROR 1 -#define MYSQLI_REPORT_STRICT 2 -#define MYSQLI_REPORT_INDEX 4 -#define MYSQLI_REPORT_CLOSE 8 -#define MYSQLI_REPORT_ALL 255 - -#define MYSQLI_REPORT_MYSQL_ERROR(mysql) \ -if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql->net.last_errno) { \ - php_mysqli_report_error(mysql->net.sqlstate, mysql->net.last_errno, mysql->net.last_error TSRMLS_CC); \ -} - -#define MYSQLI_REPORT_STMT_ERROR(stmt) \ -if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && stmt->last_errno) { \ - php_mysqli_report_error(stmt->sqlstate, stmt->last_errno, stmt->last_error TSRMLS_CC); \ -} - -PHP_MYSQLI_API void mysqli_register_link(zval *return_value, void *link TSRMLS_DC); -PHP_MYSQLI_API void mysqli_register_stmt(zval *return_value, void *stmt TSRMLS_DC); -PHP_MYSQLI_API void mysqli_register_result(zval *return_value, void *result TSRMLS_DC); -PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC); - -PHP_MINIT_FUNCTION(mysqli); -PHP_MSHUTDOWN_FUNCTION(mysqli); -PHP_RINIT_FUNCTION(mysqli); -PHP_RSHUTDOWN_FUNCTION(mysqli); -PHP_MINFO_FUNCTION(mysqli); - -PHP_FUNCTION(mysqli); -PHP_FUNCTION(mysqli_affected_rows); -PHP_FUNCTION(mysqli_autocommit); -PHP_FUNCTION(mysqli_change_user); -PHP_FUNCTION(mysqli_character_set_name); -#ifdef HAVE_MYSQLI_SET_CHARSET -PHP_FUNCTION(mysqli_set_charset); -#endif -PHP_FUNCTION(mysqli_close); -PHP_FUNCTION(mysqli_commit); -PHP_FUNCTION(mysqli_connect); -PHP_FUNCTION(mysqli_connect_errno); -PHP_FUNCTION(mysqli_connect_error); -PHP_FUNCTION(mysqli_data_seek); -PHP_FUNCTION(mysqli_debug); -PHP_FUNCTION(mysqli_disable_reads_from_master); -PHP_FUNCTION(mysqli_disable_rpl_parse); -PHP_FUNCTION(mysqli_dump_debug_info); -PHP_FUNCTION(mysqli_enable_reads_from_master); -PHP_FUNCTION(mysqli_enable_rpl_parse); -PHP_FUNCTION(mysqli_errno); -PHP_FUNCTION(mysqli_error); -PHP_FUNCTION(mysqli_fetch_array); -PHP_FUNCTION(mysqli_fetch_assoc); -PHP_FUNCTION(mysqli_fetch_object); -PHP_FUNCTION(mysqli_fetch_field); -PHP_FUNCTION(mysqli_fetch_fields); -PHP_FUNCTION(mysqli_fetch_field_direct); -PHP_FUNCTION(mysqli_fetch_lengths); -PHP_FUNCTION(mysqli_fetch_row); -PHP_FUNCTION(mysqli_field_count); -PHP_FUNCTION(mysqli_field_seek); -PHP_FUNCTION(mysqli_field_tell); -PHP_FUNCTION(mysqli_free_result); -#ifdef HAVE_MYSQLI_GET_CHARSET -PHP_FUNCTION(mysqli_get_charset); -#endif -PHP_FUNCTION(mysqli_get_client_info); -PHP_FUNCTION(mysqli_get_client_version); -PHP_FUNCTION(mysqli_get_host_info); -PHP_FUNCTION(mysqli_get_proto_info); -PHP_FUNCTION(mysqli_get_server_info); -PHP_FUNCTION(mysqli_get_server_version); -PHP_FUNCTION(mysqli_get_warnings); -PHP_FUNCTION(mysqli_info); -PHP_FUNCTION(mysqli_insert_id); -PHP_FUNCTION(mysqli_init); -PHP_FUNCTION(mysqli_kill); -PHP_FUNCTION(mysqli_set_local_infile_default); -PHP_FUNCTION(mysqli_set_local_infile_handler); -PHP_FUNCTION(mysqli_master_query); -PHP_FUNCTION(mysqli_more_results); -PHP_FUNCTION(mysqli_multi_query); -PHP_FUNCTION(mysqli_next_result); -PHP_FUNCTION(mysqli_num_fields); -PHP_FUNCTION(mysqli_num_rows); -PHP_FUNCTION(mysqli_options); -PHP_FUNCTION(mysqli_ping); -PHP_FUNCTION(mysqli_prepare); -PHP_FUNCTION(mysqli_query); -PHP_FUNCTION(mysqli_stmt_result_metadata); -PHP_FUNCTION(mysqli_report); -PHP_FUNCTION(mysqli_read_query_result); -PHP_FUNCTION(mysqli_real_connect); -PHP_FUNCTION(mysqli_real_query); -PHP_FUNCTION(mysqli_real_escape_string); -PHP_FUNCTION(mysqli_rollback); -PHP_FUNCTION(mysqli_row_seek); -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_stmt_attr_get); -PHP_FUNCTION(mysqli_stmt_attr_set); -PHP_FUNCTION(mysqli_stmt_bind_param); -PHP_FUNCTION(mysqli_stmt_bind_result); -PHP_FUNCTION(mysqli_stmt_execute); -PHP_FUNCTION(mysqli_stmt_field_count); -PHP_FUNCTION(mysqli_stmt_init); -PHP_FUNCTION(mysqli_stmt_prepare); -PHP_FUNCTION(mysqli_stmt_fetch); -PHP_FUNCTION(mysqli_stmt_param_count); -PHP_FUNCTION(mysqli_stmt_send_long_data); -PHP_FUNCTION(mysqli_send_query); -PHP_FUNCTION(mysqli_embedded_server_end); -PHP_FUNCTION(mysqli_embedded_server_start); -PHP_FUNCTION(mysqli_slave_query); -PHP_FUNCTION(mysqli_sqlstate); -PHP_FUNCTION(mysqli_ssl_set); -PHP_FUNCTION(mysqli_stat); -PHP_FUNCTION(mysqli_stmt_affected_rows); -PHP_FUNCTION(mysqli_stmt_close); -PHP_FUNCTION(mysqli_stmt_data_seek); -PHP_FUNCTION(mysqli_stmt_errno); -PHP_FUNCTION(mysqli_stmt_error); -PHP_FUNCTION(mysqli_stmt_free_result); -PHP_FUNCTION(mysqli_stmt_get_warnings); -PHP_FUNCTION(mysqli_stmt_reset); -PHP_FUNCTION(mysqli_stmt_insert_id); -PHP_FUNCTION(mysqli_stmt_num_rows); -PHP_FUNCTION(mysqli_stmt_sqlstate); -PHP_FUNCTION(mysqli_stmt_store_result); -PHP_FUNCTION(mysqli_store_result); -PHP_FUNCTION(mysqli_thread_id); -PHP_FUNCTION(mysqli_thread_safe); -PHP_FUNCTION(mysqli_use_result); -PHP_FUNCTION(mysqli_warning_count); - -ZEND_FUNCTION(mysqli_stmt_construct); -ZEND_FUNCTION(mysqli_result_construct); -ZEND_FUNCTION(mysqli_driver_construct); -ZEND_METHOD(mysqli_warning,__construct); - -ZEND_BEGIN_MODULE_GLOBALS(mysqli) - long default_link; - long num_links; - long max_links; - unsigned int default_port; - char *default_host; - char *default_user; - char *default_socket; - char *default_pw; - int reconnect; - int strict; - long error_no; - char *error_msg; - int report_mode; - HashTable *report_ht; - unsigned int multi_query; - unsigned int embedded; -ZEND_END_MODULE_GLOBALS(mysqli) - - -#define MYSQLI_PROPERTY(a) extern int a(mysqli_object *obj, zval **retval TSRMLS_DC) - -MYSQLI_PROPERTY(my_prop_link_host); - -#ifdef ZTS -#define MyG(v) TSRMG(mysqli_globals_id, zend_mysqli_globals *, v) -#else -#define MyG(v) (mysqli_globals.v) -#endif - -#define my_estrdup(x) (x) ? estrdup(x) : NULL -#define my_efree(x) if (x) efree(x) - -#ifdef PHP_WIN32 -#define L64(x) x##i64 -typedef __int64 my_longlong; -#else -#define L64(x) x##LL -typedef long long my_longlong; -#endif - - -ZEND_EXTERN_MODULE_GLOBALS(mysqli) - -#endif /* PHP_MYSQLI.H */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/mysqli/tests/001.phpt b/ext/mysqli/tests/001.phpt deleted file mode 100644 index 3f2f3c2d31..0000000000 --- a/ext/mysqli/tests/001.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -mysqli connect ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $dbname = "test"; - $test = ""; - - /*** test mysqli_connect localhost:port ***/ - $link = mysqli_connect($host, $user, $passwd, "", 3306); - $test .= ($link) ? "1" : "0"; - mysqli_close($link); - - /*** test mysqli_real_connect ***/ - $link = mysqli_init(); - $test.= (mysqli_real_connect($link, $host, $user, $passwd)) - ? "1" : "0"; - mysqli_close($link); - - /*** test mysqli_real_connect with db ***/ - $link = mysqli_init(); - $test .= (mysqli_real_connect($link, $host, $user, $passwd, $dbname)) - ? "1" : "0"; - mysqli_close($link); - - /*** test mysqli_real_connect with port ***/ - $link = mysqli_init(); - $test .= (mysqli_real_connect($link, $host, $user, $passwd, $dbname, 3306)) - ? "1":"0"; - mysqli_close($link); - - /*** test mysqli_real_connect compressed ***/ - $link = mysqli_init(); - $test .= (mysqli_real_connect($link, $host, $user, $passwd, $dbname, 0, NULL, MYSQLI_CLIENT_COMPRESS)) - ? "1" : "0"; - mysqli_close($link); - - /* todo ssl connections */ - - var_dump($test); -?> ---EXPECT-- -string(5) "11111" diff --git a/ext/mysqli/tests/002.phpt b/ext/mysqli/tests/002.phpt deleted file mode 100644 index 301af98939..0000000000 --- a/ext/mysqli/tests/002.phpt +++ /dev/null @@ -1,63 +0,0 @@ ---TEST-- -mysqli bind_result 1 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - $link->query("CREATE SCHEMA test"); - - mysqli_select_db($link, "test"); - $rc = mysqli_query($link,"DROP TABLE IF EXISTS test_fetch_null"); - - $rc = mysqli_query($link,"CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint, - col3 int, col4 bigint, - col5 float, col6 double, - col7 date, col8 time, - col9 varbinary(10), - col10 varchar(50), - col11 char(20))"); - - $rc = mysqli_query($link,"INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)"); - - $stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11); - mysqli_execute($stmt); - - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(11) { - [0]=> - int(1) - [1]=> - NULL - [2]=> - NULL - [3]=> - NULL - [4]=> - NULL - [5]=> - NULL - [6]=> - NULL - [7]=> - NULL - [8]=> - NULL - [9]=> - string(4) "foo1" - [10]=> - string(4) "1000" -} diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt deleted file mode 100644 index 28aedb032c..0000000000 --- a/ext/mysqli/tests/003.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---TEST-- -mysqli connect ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd, "test"); - - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); - mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time, - c3 timestamp(14), - c4 year, - c5 datetime, - c6 timestamp(4), - c7 timestamp(6))"); - - mysqli_query($link,"INSERT INTO test_bind_result VALUES('2002-01-02', - '12:49:00', - '2002-01-02 17:46:59', - 2010, - '2010-07-10', - '2020','1999-12-29')"); - - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - string(10) "2002-01-02" - [1]=> - string(8) "12:49:00" - [2]=> - string(19) "2002-01-02 17:46:59" - [3]=> - int(2010) - [4]=> - string(19) "2010-07-10 00:00:00" - [5]=> - string(19) "0000-00-00 00:00:00" - [6]=> - string(19) "1999-12-29 00:00:00" -} diff --git a/ext/mysqli/tests/004.phpt b/ext/mysqli/tests/004.phpt deleted file mode 100644 index fafc30ba0d..0000000000 --- a/ext/mysqli/tests/004.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -mysqli fetch char/text ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include ("connect.inc"); - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)"); - - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')"); - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')"); - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')"); - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1"); - mysqli_bind_result($stmt, $c1, $c2); - mysqli_execute($stmt); - $i=4; - while ($i--) { - mysqli_fetch($stmt); - $test = array($c1,$c2); - var_dump($test); - } - - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(10) "1234567890" - [1]=> - string(15) "this is a test0" -} -array(2) { - [0]=> - string(10) "1234567891" - [1]=> - string(15) "this is a test1" -} -array(2) { - [0]=> - string(10) "1234567892" - [1]=> - string(15) "this is a test2" -} -array(2) { - [0]=> - string(10) "1234567893" - [1]=> - string(15) "this is a test3" -} diff --git a/ext/mysqli/tests/005.phpt b/ext/mysqli/tests/005.phpt deleted file mode 100644 index a9f75cfd7e..0000000000 --- a/ext/mysqli/tests/005.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -mysqli fetch char/text long ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)"); - - $a = str_repeat("A1", 32000); - - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', '$a')"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test[] = $c1; - $test[] = ($a == $c2) ? "32K String ok" : "32K String failed"; - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(10) "1234567890" - [1]=> - string(13) "32K String ok" -} diff --git a/ext/mysqli/tests/006.phpt b/ext/mysqli/tests/006.phpt deleted file mode 100644 index a53ad7a547..0000000000 --- a/ext/mysqli/tests/006.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -mysqli fetch long values ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned, - c2 int unsigned, - c3 int, - c4 int, - c5 int, - c6 int unsigned, - c7 int)"); - - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,35999,NULL,-500,-9999999,-0,0)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - int(0) - [1]=> - int(35999) - [2]=> - NULL - [3]=> - int(-500) - [4]=> - int(-9999999) - [5]=> - int(0) - [6]=> - int(0) -} diff --git a/ext/mysqli/tests/007.phpt b/ext/mysqli/tests/007.phpt deleted file mode 100644 index cb32033cca..0000000000 --- a/ext/mysqli/tests/007.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -mysqli fetch short values ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned, - c2 smallint unsigned, - c3 smallint, - c4 smallint, - c5 smallint, - c6 smallint unsigned, - c7 smallint)"); - - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,35999,NULL,-500,-9999999,+30,0)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - int(0) - [1]=> - int(35999) - [2]=> - NULL - [3]=> - int(-500) - [4]=> - int(-32768) - [5]=> - int(30) - [6]=> - int(0) -} diff --git a/ext/mysqli/tests/008.phpt b/ext/mysqli/tests/008.phpt deleted file mode 100644 index 9fc01b8adf..0000000000 --- a/ext/mysqli/tests/008.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -mysqli fetch tinyint values ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint, - c2 tinyint unsigned, - c3 tinyint not NULL, - c4 tinyint, - c5 tinyint, - c6 tinyint unsigned, - c7 tinyint)"); - - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - int(-23) - [1]=> - int(255) - [2]=> - int(0) - [3]=> - int(-100) - [4]=> - int(-127) - [5]=> - int(30) - [6]=> - int(0) -} diff --git a/ext/mysqli/tests/009.phpt b/ext/mysqli/tests/009.phpt deleted file mode 100644 index 32ed3c18f0..0000000000 --- a/ext/mysqli/tests/009.phpt +++ /dev/null @@ -1,79 +0,0 @@ ---TEST-- -mysqli fetch bigint values (ok to fail with 4.1.x) ---SKIPIF-- -<?php - if (PHP_INT_SIZE == 8) { - echo 'skip test valid only for 32bit systems'; - exit; - } - require_once('skipif.inc'); -?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 bigint default 5, - c2 bigint, - c3 bigint not NULL, - c4 bigint unsigned, - c5 bigint unsigned, - c6 bigint unsigned, - c7 bigint unsigned)"); - - mysqli_query($link, "INSERT INTO test_bind_fetch (c2,c3,c4,c5,c6,c7) VALUES (-23,4.0,33333333333333,0,-333333333333,99.9)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - $rc = mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch_uint"); - mysqli_query($link,"CREATE TABLE test_bind_fetch_uint(c1 integer unsigned, c2 integer unsigned)"); - - mysqli_query($link, "INSERT INTO test_bind_fetch_uint (c1,c2) VALUES (20123456, 3123456789)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch_uint"); - mysqli_bind_result($stmt, $c1, $c2); - mysqli_execute($stmt); - $rc = mysqli_fetch($stmt); - - echo $c1, "\n", $c2, "\n"; - - mysqli_stmt_close($stmt); - - - mysqli_close($link); -?> - ---EXPECT-- -array(7) { - [0]=> - int(5) - [1]=> - int(-23) - [2]=> - int(4) - [3]=> - string(14) "33333333333333" - [4]=> - int(0) - [5]=> - int(0) - [6]=> - int(100) -} -20123456 -3123456789 diff --git a/ext/mysqli/tests/010.phpt b/ext/mysqli/tests/010.phpt deleted file mode 100644 index 6b79d62f42..0000000000 --- a/ext/mysqli/tests/010.phpt +++ /dev/null @@ -1,59 +0,0 @@ ---TEST-- -mysqli fetch float values ---INI-- -precision=12 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 float(3), - c2 float, - c3 float unsigned, - c4 float, - c5 float, - c6 float, - c7 float(10) unsigned)"); - - - mysqli_query($link, "INSERT INTO test_bind_fetch (c1,c2,c3,c4,c5,c6,c7) VALUES (3.1415926535,-0.000001, -5, 999999999999, - sin(0.6), 1.00000000000001, 888888888888888)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - float(3.14159274101) - [1]=> - float(-9.99999997475E-7) - [2]=> - float(0) - [3]=> - float(999999995904) - [4]=> - float(0.564642488956) - [5]=> - float(1) - [6]=> - float(888888914608000) -} diff --git a/ext/mysqli/tests/011.phpt b/ext/mysqli/tests/011.phpt deleted file mode 100644 index 77a157f564..0000000000 --- a/ext/mysqli/tests/011.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -mysqli fetch mixed values ---INI-- -precision=12 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); - - mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, - c3 int, c4 bigint, - c5 float, c6 double, - c7 varbinary(10), - c8 varchar(50))"); - - mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999, - 2345.6,5678.89563, - 'foobar','mysql rulez')"); - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(8) { - [0]=> - int(19) - [1]=> - int(2999) - [2]=> - int(3999) - [3]=> - int(4999999) - [4]=> - float(2345.60009766) - [5]=> - float(5678.89563) - [6]=> - string(6) "foobar" - [7]=> - string(11) "mysql rulez" -} diff --git a/ext/mysqli/tests/012.phpt b/ext/mysqli/tests/012.phpt deleted file mode 100644 index 9c52f9c3e4..0000000000 --- a/ext/mysqli/tests/012.phpt +++ /dev/null @@ -1,58 +0,0 @@ ---TEST-- -mysqli fetch mixed values 2 ---INI-- -precision=12 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); - - mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, - c3 int, c4 bigint, - c5 float, c6 double, - c7 varbinary(10), - c8 varchar(10))"); - - mysqli_query($link,"INSERT INTO test_bind_result VALUES(120,2999,3999,54, - 2.6,58.89, - '206','6.7')"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(8) { - [0]=> - int(120) - [1]=> - int(2999) - [2]=> - int(3999) - [3]=> - int(54) - [4]=> - float(2.59999990463) - [5]=> - float(58.89) - [6]=> - string(3) "206" - [7]=> - string(3) "6.7" -} diff --git a/ext/mysqli/tests/013.phpt b/ext/mysqli/tests/013.phpt deleted file mode 100644 index 60caff5b8a..0000000000 --- a/ext/mysqli/tests/013.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -mysqli fetch mixed / mysql_query (may fail when using 4.1 library with 5.x server) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); - - mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint, - c3 int, c4 bigint, - c5 decimal(4,2), c6 double, - c7 varbinary(10), - c8 varchar(10))"); - - mysqli_query($link,"INSERT INTO test_bind_result VALUES(120,2999,3999,54, - 2.6,58.89, - '206','6.7')"); - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); - - $c = array(0,0,0,0,0,0,0,0); - $b_res= mysqli_bind_result($stmt, $c[0], $c[1], $c[2], $c[3], $c[4], $c[5], $c[6], $c[7]); - mysqli_execute($stmt); - mysqli_fetch($stmt); - mysqli_fetch($stmt); - mysqli_stmt_close($stmt); - - $result = mysqli_query($link, "select * from test_bind_result"); - $d = mysqli_fetch_row($result); - mysqli_free_result($result); - - $test = ""; - for ($i=0; $i < count($c); $i++) - $test .= ($c[0] == $d[0]) ? "1" : "0"; - if ($test == "11111111") - echo "ok"; - else if ($b_res == FALSE && mysqli_get_client_version() > 40100 && mysqli_get_client_version() < 50000 && - mysqli_get_server_version($link) > 50000) - echo "error (4.1 library with 5.x server)"; - else - echo "error"; - - mysqli_close($link); -?> ---EXPECTF-- -ok diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt deleted file mode 100644 index d6591fcab4..0000000000 --- a/ext/mysqli/tests/014.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -mysqli autocommit/commit/rollback ---SKIPIF-- -<?php - require_once('skipif.inc'); - include "connect.inc"; - $link = mysqli_connect($host, $user, $passwd); - $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'"); - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - mysqli_close($link); - if ($row[1] == "DISABLED" || $row[1] == "NO") { - printf ("skip innodb support is not installed or enabled."); - exit; - } -?> ---FILE-- -<?php - include "connect.inc"; - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_autocommit($link, TRUE); - - mysqli_query($link,"DROP TABLE IF EXISTS ac_01"); - - mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10)) type=InnoDB"); - - mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')"); - mysqli_autocommit($link, FALSE); - mysqli_query($link, "DELETE FROM ac_01"); - mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); - - mysqli_rollback($link); - - $result = mysqli_query($link, "SELECT * FROM ac_01"); - printf("Num_of_rows=%d\n", mysqli_num_rows($result)); - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - - var_dump($row); - - mysqli_query($link, "DELETE FROM ac_01"); - mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); - mysqli_commit($link); - - $result = mysqli_query($link, "SELECT * FROM ac_01"); - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - - var_dump($row); - - mysqli_close($link); -?> ---EXPECT-- -Num_of_rows=1 -array(2) { - [0]=> - string(1) "1" - [1]=> - string(6) "foobar" -} -array(2) { - [0]=> - string(1) "2" - [1]=> - string(4) "egon" -} diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt deleted file mode 100644 index 7620f3c435..0000000000 --- a/ext/mysqli/tests/015.phpt +++ /dev/null @@ -1,69 +0,0 @@ ---TEST-- -mysqli autocommit/commit/rollback with myisam ---SKIPIF-- -<?php - require_once('skipif.inc'); - include "connect.inc"; - $link = mysqli_connect($host, $user, $passwd); - $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'"); - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - mysqli_close($link); - - if ($row[1] == "NO") { - printf ("skip innodb support not installed."); - } -?> ---FILE-- -<?php - include "connect.inc"; - - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_autocommit($link, TRUE); - - mysqli_query($link,"DROP TABLE IF EXISTS ac_01"); - - mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10))"); - - mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')"); - mysqli_autocommit($link, FALSE); - - mysqli_query($link, "DELETE FROM ac_01"); - mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); - - mysqli_rollback($link); - - $result = mysqli_query($link, "SELECT * FROM ac_01"); - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - - var_dump($row); - - mysqli_query($link, "DELETE FROM ac_01"); - mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); - mysqli_commit($link); - - $result = mysqli_query($link, "SELECT * FROM ac_01"); - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - - var_dump($row); - - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(1) "2" - [1]=> - string(4) "egon" -} -array(2) { - [0]=> - string(1) "2" - [1]=> - string(4) "egon" -} diff --git a/ext/mysqli/tests/016.phpt b/ext/mysqli/tests/016.phpt deleted file mode 100644 index c61da29ec1..0000000000 --- a/ext/mysqli/tests/016.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -mysqli fetch user variable ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "SET @dummy='foobar'"); - - $stmt = mysqli_prepare($link, "SELECT @dummy"); - mysqli_bind_result($stmt, $dummy); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - var_dump($dummy); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -string(6) "foobar" diff --git a/ext/mysqli/tests/017.phpt b/ext/mysqli/tests/017.phpt deleted file mode 100644 index 866a118a86..0000000000 --- a/ext/mysqli/tests/017.phpt +++ /dev/null @@ -1,35 +0,0 @@ ---TEST-- -mysqli fetch functions ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - $stmt = mysqli_prepare($link, "SELECT md5('bar'), database(), 'foo'"); - mysqli_bind_result($stmt, $c0, $c1, $c2); - mysqli_execute($stmt); - - mysqli_fetch($stmt); - mysqli_stmt_close($stmt); - - $test = array($c0, $c1, $c2); - - var_dump($test); - mysqli_close($link); -?> ---EXPECT-- -array(3) { - [0]=> - string(32) "37b51d194a7513e45b56f6524f2d51f2" - [1]=> - string(4) "test" - [2]=> - string(3) "foo" -} diff --git a/ext/mysqli/tests/018.phpt b/ext/mysqli/tests/018.phpt deleted file mode 100644 index 4ba199d866..0000000000 --- a/ext/mysqli/tests/018.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -mysqli fetch system variables ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "SET AUTOCOMMIT=0"); - - $stmt = mysqli_prepare($link, "SELECT @@autocommit"); - mysqli_bind_result($stmt, $c0); - mysqli_execute($stmt); - - mysqli_fetch($stmt); - - var_dump($c0); - - mysqli_close($link); -?> ---EXPECT-- -int(0) diff --git a/ext/mysqli/tests/019.phpt b/ext/mysqli/tests/019.phpt deleted file mode 100644 index 173c404909..0000000000 --- a/ext/mysqli/tests/019.phpt +++ /dev/null @@ -1,71 +0,0 @@ ---TEST-- -mysqli fetch (bind_param + bind_result) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - $rc = mysqli_query($link,"DROP TABLE IF EXISTS insert_read"); - - $rc = mysqli_query($link,"CREATE TABLE insert_read(col1 tinyint, col2 smallint, - col3 int, col4 bigint, - col5 float, col6 double, - col7 date, col8 time, - col9 varbinary(10), - col10 varchar(50), - col11 char(20))"); - - $stmt= mysqli_prepare($link,"INSERT INTO insert_read(col1,col10, col11, col6) VALUES(?,?,?,?)"); - mysqli_bind_param($stmt, "issd", $c1, $c2, $c3, $c4); - - $c1 = 1; - $c2 = "foo"; - $c3 = "foobar"; - $c4 = 3.14; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from insert_read"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11); - mysqli_execute($stmt); - - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(11) { - [0]=> - int(1) - [1]=> - NULL - [2]=> - NULL - [3]=> - NULL - [4]=> - NULL - [5]=> - float(3.14) - [6]=> - NULL - [7]=> - NULL - [8]=> - NULL - [9]=> - string(3) "foo" - [10]=> - string(6) "foobar" -} diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt deleted file mode 100644 index 4ae140f620..0000000000 --- a/ext/mysqli/tests/020.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -mysqli bind_param/bind_result date ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"); - mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time, - c3 timestamp(14), - c4 year, - c5 datetime, - c6 timestamp(4), - c7 timestamp(6))"); - - $stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)"); - mysqli_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7); - - $d1 = '2002-01-02'; - $d2 = '12:49:00'; - $d3 = '2002-01-02 17:46:59'; - $d4 = 2010; - $d5 ='2010-07-10'; - $d6 = '2020'; - $d7 = '1999-12-29'; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result"); - - mysqli_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7); - - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - string(10) "2002-01-02" - [1]=> - string(8) "12:49:00" - [2]=> - string(19) "2002-01-02 17:46:59" - [3]=> - int(2010) - [4]=> - string(19) "2010-07-10 00:00:00" - [5]=> - string(19) "0000-00-00 00:00:00" - [6]=> - string(19) "1999-12-29 00:00:00" -} diff --git a/ext/mysqli/tests/021.phpt b/ext/mysqli/tests/021.phpt deleted file mode 100644 index 6f5bad3205..0000000000 --- a/ext/mysqli/tests/021.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -mysqli bind_param+bind_result char/text ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)"); - - $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)"); - mysqli_bind_param($stmt, "ss", $q1, $q2); - $q1 = "1234567890"; - $q2 = "this is a test"; - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(10) "1234567890" - [1]=> - string(14) "this is a test" -} diff --git a/ext/mysqli/tests/022.phpt b/ext/mysqli/tests/022.phpt deleted file mode 100644 index cce8ed8eb6..0000000000 --- a/ext/mysqli/tests/022.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -mysqli bind_param/bind_result char/text long ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)"); - - - $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)"); - mysqli_bind_param($stmt, "ss", $a1, $a2); - - $a1 = "1234567890"; - $a2 = str_repeat("A1", 32000); - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test[] = $c1; - $test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed"; - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(10) "1234567890" - [1]=> - string(13) "32K String ok" -} diff --git a/ext/mysqli/tests/023.phpt b/ext/mysqli/tests/023.phpt deleted file mode 100644 index 24a717a6eb..0000000000 --- a/ext/mysqli/tests/023.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -mysqli bind_param/bind_prepare fetch long values ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned, - c2 int unsigned, - c3 int, - c4 int, - c5 int, - c6 int unsigned, - c7 int)"); - - $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)"); - mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7); - $c1 = -23; - $c2 = 35999; - $c3 = NULL; - $c4 = -500; - $c5 = -9999999; - $c6 = -0; - $c7 = 0; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - int(0) - [1]=> - int(35999) - [2]=> - NULL - [3]=> - int(-500) - [4]=> - int(-9999999) - [5]=> - int(0) - [6]=> - int(0) -} diff --git a/ext/mysqli/tests/024.phpt b/ext/mysqli/tests/024.phpt deleted file mode 100644 index f0d0a6407a..0000000000 --- a/ext/mysqli/tests/024.phpt +++ /dev/null @@ -1,66 +0,0 @@ ---TEST-- -mysqli bind_param/bind_result short values ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned, - c2 smallint unsigned, - c3 smallint, - c4 smallint, - c5 smallint, - c6 smallint unsigned, - c7 smallint)"); - - $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)"); - mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7); - - $c1 = -23; - $c2 = 35999; - $c3 = NULL; - $c4 = -500; - $c5 = -9999999; - $c6 = -0; - $c7 = 0; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - int(0) - [1]=> - int(35999) - [2]=> - NULL - [3]=> - int(-500) - [4]=> - int(-32768) - [5]=> - int(0) - [6]=> - int(0) -} diff --git a/ext/mysqli/tests/025.phpt b/ext/mysqli/tests/025.phpt deleted file mode 100644 index f3338cf467..0000000000 --- a/ext/mysqli/tests/025.phpt +++ /dev/null @@ -1,70 +0,0 @@ ---TEST-- -mysqli bind_param/bind_result tinyint values ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint, - c2 tinyint unsigned, - c3 tinyint not NULL, - c4 tinyint, - c5 tinyint, - c6 tinyint unsigned, - c7 tinyint)"); - - $stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)"); - mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7); - - $c1 = -23; - $c2 = 300; - $c3 = 0; - $c4 = -100; - $c5 = -127; - $c6 = 30; - $c7 = 0; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)"); - - $c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL; - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7); - - var_dump($test); - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -array(7) { - [0]=> - int(-23) - [1]=> - int(255) - [2]=> - int(0) - [3]=> - int(-100) - [4]=> - int(-127) - [5]=> - int(30) - [6]=> - int(0) -} diff --git a/ext/mysqli/tests/026.phpt b/ext/mysqli/tests/026.phpt deleted file mode 100644 index d38e3c1807..0000000000 --- a/ext/mysqli/tests/026.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -mysqli bind_param/bind_result with send_long_data ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)"); - - $stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)"); - mysqli_bind_param($stmt, "sb", $c1, $c2); - - $c1 = "Hello World"; - - mysqli_send_long_data($stmt, 1, "This is the first sentence."); - mysqli_send_long_data($stmt, 1, " And this is the second sentence."); - mysqli_send_long_data($stmt, 1, " And finally this is the last sentence."); - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch"); - mysqli_bind_result($stmt, $d1, $d2); - mysqli_execute($stmt); - mysqli_fetch($stmt); - - $test = array($d1,$d2); - - var_dump($test); - - mysqli_stmt_close($stmt); - - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(10) "Hello Worl" - [1]=> - string(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence." -} diff --git a/ext/mysqli/tests/027.phpt b/ext/mysqli/tests/027.phpt deleted file mode 100644 index 9f8eadf9dd..0000000000 --- a/ext/mysqli/tests/027.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -function test: mysqli_stat ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $status = mysqli_stat($link); - - - var_dump(strlen($status) > 0); - - mysqli_close($link); -?> ---EXPECT-- -bool(true) diff --git a/ext/mysqli/tests/028.phpt b/ext/mysqli/tests/028.phpt deleted file mode 100644 index 0e897d86f8..0000000000 --- a/ext/mysqli/tests/028.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -function test: mysqli_character_set_name ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $cset = substr(mysqli_character_set_name($link),0,6); - - var_dump($cset); - - mysqli_close($link); -?> ---EXPECTF-- -string(%d) "%s" diff --git a/ext/mysqli/tests/029.phpt b/ext/mysqli/tests/029.phpt deleted file mode 100644 index 318e6aeb9e..0000000000 --- a/ext/mysqli/tests/029.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -function test: mysqli_affected_rows ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "drop table if exists general_test"); - mysqli_query($link, "create table general_test (a int)"); - mysqli_query($link, "insert into general_test values (1),(2),(3)"); - - $afc = mysqli_affected_rows($link); - - var_dump($afc); - - mysqli_close($link); -?> ---EXPECT-- -int(3) diff --git a/ext/mysqli/tests/030.phpt b/ext/mysqli/tests/030.phpt deleted file mode 100644 index a3946c3715..0000000000 --- a/ext/mysqli/tests/030.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -function test: mysqli_errno ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - $errno = mysqli_errno($link); - var_dump($errno); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "select * from non_exisiting_table"); - $errno = mysqli_errno($link); - - var_dump($errno); - - mysqli_close($link); -?> ---EXPECT-- -int(0) -int(1146) diff --git a/ext/mysqli/tests/031.phpt b/ext/mysqli/tests/031.phpt deleted file mode 100644 index 743b4b2d0f..0000000000 --- a/ext/mysqli/tests/031.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -function test: mysqli_error ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - $error = mysqli_error($link); - var_dump($error); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "select * from non_exisiting_table"); - $error = mysqli_error($link); - - var_dump($error); - - mysqli_close($link); -?> ---EXPECT-- -string(0) "" -string(46) "Table 'test.non_exisiting_table' doesn't exist" diff --git a/ext/mysqli/tests/032.phpt b/ext/mysqli/tests/032.phpt deleted file mode 100644 index 18bd756a23..0000000000 --- a/ext/mysqli/tests/032.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -function test: mysqli_info ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "drop table if exists general_test"); - mysqli_query($link, "create table general_test (a int)"); - mysqli_query($link, "insert into general_test values (1),(2),(3)"); - - $afc = mysqli_info($link); - - var_dump($afc); - - mysqli_close($link); -?> ---EXPECT-- -string(38) "Records: 3 Duplicates: 0 Warnings: 0" diff --git a/ext/mysqli/tests/033.phpt b/ext/mysqli/tests/033.phpt deleted file mode 100644 index de401f49de..0000000000 --- a/ext/mysqli/tests/033.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -function test: mysqli_get_host_info ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $hinfo = mysqli_get_host_info($link); - - var_dump(str_replace('/','', $hinfo)); - - mysqli_close($link); -?> ---EXPECTF-- -string(%d) "%s via %s" diff --git a/ext/mysqli/tests/034.phpt b/ext/mysqli/tests/034.phpt deleted file mode 100644 index 468861c3c2..0000000000 --- a/ext/mysqli/tests/034.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -function test: mysqli_get_proto_info ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $pinfo = mysqli_get_proto_info($link); - - var_dump($pinfo); - - mysqli_close($link); -?> ---EXPECT-- -int(10) diff --git a/ext/mysqli/tests/035.phpt b/ext/mysqli/tests/035.phpt deleted file mode 100644 index ea31222ec7..0000000000 --- a/ext/mysqli/tests/035.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -function test: mysqli_get_server_info ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $sinfo = substr(mysqli_get_server_info($link),0,1); - - var_dump(strlen($sinfo)); - - mysqli_close($link); -?> ---EXPECT-- -int(1) diff --git a/ext/mysqli/tests/036.phpt b/ext/mysqli/tests/036.phpt deleted file mode 100644 index 057795bb4c..0000000000 --- a/ext/mysqli/tests/036.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -function test: mysqli_insert_id() ---SKIPIF-- -<?php - if (PHP_INT_SIZE == 8) { - echo 'skip test valid only for 32bit systems'; - exit; - } - require_once('skipif.inc'); -?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS t036"); - - mysqli_query($link, "CREATE TABLE t036 (a bigint not null auto_increment primary key, b varchar(10))"); - - - mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo1')"); - $test[] = mysqli_insert_id($link); - - /* we have to insert more values, cause lexer sets auto_increment to max_int - see mysql bug #54. So we don't check for the value, only for type (which must - be type string) - */ - - mysqli_query($link, "ALTER TABLE t036 AUTO_INCREMENT=9999999999999998"); - mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo2')"); - mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo3')"); - mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo4')"); - $x = mysqli_insert_id($link); - $test[] = is_string($x); - - var_dump($test); - - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - int(1) - [1]=> - bool(true) -} diff --git a/ext/mysqli/tests/037.phpt b/ext/mysqli/tests/037.phpt deleted file mode 100644 index c9089c19be..0000000000 --- a/ext/mysqli/tests/037.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -function test: mysqli_field_count() ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS test_result"); - - mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))"); - - mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')"); - $ir[] = mysqli_field_count($link); - - mysqli_real_query($link, "SELECT * FROM test_result"); - $ir[] = mysqli_field_count($link); - - - var_dump($ir); - - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - int(0) - [1]=> - int(2) -} diff --git a/ext/mysqli/tests/038.phpt b/ext/mysqli/tests/038.phpt deleted file mode 100644 index ecd4f908f1..0000000000 --- a/ext/mysqli/tests/038.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -function test: mysqli_num_fields() ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS test_result"); - - mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))"); - - mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')"); - - mysqli_real_query($link, "SELECT * FROM test_result"); - if (mysqli_field_count($link)) { - $result = mysqli_store_result($link); - $num = mysqli_num_fields($result); - mysqli_free_result($result); - } - - var_dump($num); - - mysqli_close($link); -?> ---EXPECT-- -int(2) diff --git a/ext/mysqli/tests/039.phpt b/ext/mysqli/tests/039.phpt deleted file mode 100644 index 1d5ab99106..0000000000 --- a/ext/mysqli/tests/039.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -function test: mysqli_num_fields() 2 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_real_query($link, "SHOW VARIABLES"); - - if (mysqli_field_count($link)) { - $result = mysqli_store_result($link); - $num = mysqli_num_fields($result); - mysqli_free_result($result); - } - - var_dump($num); - - mysqli_close($link); -?> ---EXPECT-- -int(2) diff --git a/ext/mysqli/tests/040.phpt b/ext/mysqli/tests/040.phpt deleted file mode 100644 index 79bfe0d5fb..0000000000 --- a/ext/mysqli/tests/040.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -function test: mysqli_num_rows() ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS test_result"); - - mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))"); - - mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')"); - - mysqli_real_query($link, "SELECT * FROM test_result"); - if (mysqli_field_count($link)) { - $result = mysqli_store_result($link); - $num = mysqli_num_rows($result); - mysqli_free_result($result); - } - - var_dump($num); - - mysqli_close($link); -?> ---EXPECT-- -int(1) diff --git a/ext/mysqli/tests/041.phpt b/ext/mysqli/tests/041.phpt deleted file mode 100644 index 90bed1ad49..0000000000 --- a/ext/mysqli/tests/041.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -function test: mysqli_warning_count() ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"); - mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"); - - var_dump(mysqli_warning_count($link)); - - mysqli_close($link); -?> ---EXPECT-- -int(1) diff --git a/ext/mysqli/tests/042.phpt b/ext/mysqli/tests/042.phpt deleted file mode 100644 index 719e24925d..0000000000 --- a/ext/mysqli/tests/042.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -mysqli_fetch_object ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"); - mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned, - c2 smallint unsigned, - c3 smallint, - c4 smallint, - c5 smallint, - c6 smallint unsigned, - c7 smallint)"); - - $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)"); - mysqli_bind_param($stmt, "iiiiiii", $c1,$c2,$c3,$c4,$c5,$c6,$c7); - - $c1 = -23; - $c2 = 35999; - $c3 = NULL; - $c4 = -500; - $c5 = -9999999; - $c6 = -0; - $c7 = 0; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $result = mysqli_query($link, "SELECT * FROM test_bind_fetch"); - $test = mysqli_fetch_object($result); - mysqli_free_result($result); - - var_dump($test); - - mysqli_close($link); -?> ---EXPECTF-- -object(stdClass)#%d (7) { - ["c1"]=> - string(1) "0" - ["c2"]=> - string(5) "35999" - ["c3"]=> - NULL - ["c4"]=> - string(4) "-500" - ["c5"]=> - string(6) "-32768" - ["c6"]=> - string(1) "0" - ["c7"]=> - string(1) "0" -} diff --git a/ext/mysqli/tests/043.phpt b/ext/mysqli/tests/043.phpt deleted file mode 100644 index fb0284e06a..0000000000 --- a/ext/mysqli/tests/043.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -mysqli_bind_param (UPDATE) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_update"); - mysqli_query($link,"CREATE TABLE test_update(a varchar(10), - b int)"); - - mysqli_query($link, "INSERT INTO test_update VALUES ('foo', 2)"); - - $stmt = mysqli_prepare($link, "UPDATE test_update SET a=?,b=? WHERE b=?"); - mysqli_bind_param($stmt, "sii", $c1, $c2, $c3); - - $c1 = "Rasmus"; - $c2 = 1; - $c3 = 2; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $result = mysqli_query($link, "SELECT concat(a, ' is No. ', b) FROM test_update"); - $test = mysqli_fetch_row($result); - mysqli_free_result($result); - - var_dump($test); - - mysqli_close($link); -?> ---EXPECT-- -array(1) { - [0]=> - string(15) "Rasmus is No. 1" -} diff --git a/ext/mysqli/tests/044.phpt b/ext/mysqli/tests/044.phpt deleted file mode 100644 index 28e73a7e09..0000000000 --- a/ext/mysqli/tests/044.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -mysqli_get_server_version ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $i = mysqli_get_server_version($link); - - $test = $i / $i; - - var_dump($test); - - mysqli_close($link); -?> ---EXPECT-- -int(1) diff --git a/ext/mysqli/tests/045.phpt b/ext/mysqli/tests/045.phpt deleted file mode 100644 index dd491a6977..0000000000 --- a/ext/mysqli/tests/045.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -mysqli_bind_result (SHOW) ---SKIPIF-- -<?php - require_once('skipif.inc'); - require_once('skipifemb.inc'); - - include "connect.inc"; - $link = mysqli_connect($host, $user, $passwd); - - - $stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'"); - mysqli_execute($stmt); - - if (!$stmt->field_count) { - printf("skip SHOW command is not supported in prepared statements."); - } - $stmt->close(); - mysqli_close($link); -?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - $stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'"); - mysqli_execute($stmt); - - mysqli_bind_result($stmt, $c1, $c2); - mysqli_fetch($stmt); - mysqli_stmt_close($stmt); - $test = array ($c1,$c2); - - var_dump($test); - - mysqli_close($link); -?> ---EXPECT-- -array(2) { - [0]=> - string(4) "port" - [1]=> - string(4) "3306" -} diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt deleted file mode 100644 index e88348bfa9..0000000000 --- a/ext/mysqli/tests/046.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -mysqli_stmt_affected_rows (delete) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS test_affected"); - mysqli_query($link, "CREATE TABLE test_affected (foo int)"); - - mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)"); - - $stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?"); - mysqli_bind_param($stmt, "i", $c1); - - $c1 = 2; - - mysqli_execute($stmt); - $x = mysqli_stmt_affected_rows($stmt); - - mysqli_stmt_close($stmt); - var_dump($x==1); - - mysqli_close($link); -?> ---EXPECT-- -bool(true) diff --git a/ext/mysqli/tests/047.phpt b/ext/mysqli/tests/047.phpt deleted file mode 100644 index 4b5df98676..0000000000 --- a/ext/mysqli/tests/047.phpt +++ /dev/null @@ -1,196 +0,0 @@ ---TEST-- -mysqli_get_metadata ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "DROP TABLE IF EXISTS test_affected"); - mysqli_query($link, "CREATE TABLE test_affected (foo int, bar varchar(10) character set latin1)"); - - mysqli_query($link, "INSERT INTO test_affected VALUES (1, 'Zak'),(2, 'Greant')"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_affected"); - mysqli_execute($stmt); - $result = mysqli_get_metadata($stmt); - - echo "\n=== fetch_fields ===\n"; - var_dump(mysqli_fetch_fields($result)); - - echo "\n=== fetch_field_direct ===\n"; - var_dump(mysqli_fetch_field_direct($result, 0)); - var_dump(mysqli_fetch_field_direct($result, 1)); - - echo "\n=== fetch_field ===\n"; - while ($field = mysqli_fetch_field($result)) { - var_dump($field); - } - - print_r(mysqli_fetch_lengths($result)); - - mysqli_free_result($result); - - - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECTF-- -=== fetch_fields === -array(2) { - [0]=> - object(stdClass)#5 (11) { - ["name"]=> - string(3) "foo" - ["orgname"]=> - string(3) "foo" - ["table"]=> - string(13) "test_affected" - ["orgtable"]=> - string(13) "test_affected" - ["def"]=> - string(0) "" - ["max_length"]=> - int(0) - ["length"]=> - int(11) - ["charsetnr"]=> - int(63) - ["flags"]=> - int(32768) - ["type"]=> - int(3) - ["decimals"]=> - int(0) - } - [1]=> - object(stdClass)#6 (11) { - ["name"]=> - string(3) "bar" - ["orgname"]=> - string(3) "bar" - ["table"]=> - string(13) "test_affected" - ["orgtable"]=> - string(13) "test_affected" - ["def"]=> - string(0) "" - ["max_length"]=> - int(0) - ["length"]=> - int(10) - ["charsetnr"]=> - int(8) - ["flags"]=> - int(0) - ["type"]=> - int(253) - ["decimals"]=> - int(0) - } -} - -=== fetch_field_direct === -object(stdClass)#6 (11) { - ["name"]=> - string(3) "foo" - ["orgname"]=> - string(3) "foo" - ["table"]=> - string(13) "test_affected" - ["orgtable"]=> - string(13) "test_affected" - ["def"]=> - string(0) "" - ["max_length"]=> - int(0) - ["length"]=> - int(11) - ["charsetnr"]=> - int(63) - ["flags"]=> - int(32768) - ["type"]=> - int(3) - ["decimals"]=> - int(0) -} -object(stdClass)#6 (11) { - ["name"]=> - string(3) "bar" - ["orgname"]=> - string(3) "bar" - ["table"]=> - string(13) "test_affected" - ["orgtable"]=> - string(13) "test_affected" - ["def"]=> - string(0) "" - ["max_length"]=> - int(0) - ["length"]=> - int(10) - ["charsetnr"]=> - int(8) - ["flags"]=> - int(0) - ["type"]=> - int(253) - ["decimals"]=> - int(0) -} - -=== fetch_field === -object(stdClass)#6 (11) { - ["name"]=> - string(3) "foo" - ["orgname"]=> - string(3) "foo" - ["table"]=> - string(13) "test_affected" - ["orgtable"]=> - string(13) "test_affected" - ["def"]=> - string(0) "" - ["max_length"]=> - int(0) - ["length"]=> - int(11) - ["charsetnr"]=> - int(63) - ["flags"]=> - int(32768) - ["type"]=> - int(3) - ["decimals"]=> - int(0) -} -object(stdClass)#5 (11) { - ["name"]=> - string(3) "bar" - ["orgname"]=> - string(3) "bar" - ["table"]=> - string(13) "test_affected" - ["orgtable"]=> - string(13) "test_affected" - ["def"]=> - string(0) "" - ["max_length"]=> - int(0) - ["length"]=> - int(10) - ["charsetnr"]=> - int(8) - ["flags"]=> - int(0) - ["type"]=> - int(253) - ["decimals"]=> - int(0) -}
\ No newline at end of file diff --git a/ext/mysqli/tests/048.phpt b/ext/mysqli/tests/048.phpt deleted file mode 100644 index 1cf5b67894..0000000000 --- a/ext/mysqli/tests/048.phpt +++ /dev/null @@ -1,62 +0,0 @@ ---TEST-- -mysqli bind_result (OO-Style) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $mysql = mysqli_connect($host, $user, $passwd); - - $mysql->select_db("test"); - $mysql->query("DROP TABLE IF EXISTS test_fetch_null"); - - $mysql->query("CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint, - col3 int, col4 bigint, - col5 float, col6 double, - col7 date, col8 time, - col9 varbinary(10), - col10 varchar(50), - col11 char(20))"); - - $mysql->query("INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)"); - - $stmt = $mysql->prepare("SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null"); - $stmt->bind_result($c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11); - $stmt->execute(); - - $stmt->fetch(); - - $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11); - - var_dump($test); - - $stmt->close(); - $mysql->close(); -?> ---EXPECT-- -array(11) { - [0]=> - int(1) - [1]=> - NULL - [2]=> - NULL - [3]=> - NULL - [4]=> - NULL - [5]=> - NULL - [6]=> - NULL - [7]=> - NULL - [8]=> - NULL - [9]=> - string(4) "foo1" - [10]=> - string(4) "1000" -} diff --git a/ext/mysqli/tests/049.phpt b/ext/mysqli/tests/049.phpt deleted file mode 100644 index 4bb5bfef45..0000000000 --- a/ext/mysqli/tests/049.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -mysql_fetch_row (OO-Style) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $mysql = mysqli_connect($host, $user, $passwd); - - $mysql->select_db("test"); - $result = $mysql->query("SELECT DATABASE()"); - $row = $result->fetch_row(); - $result->close(); - - var_dump($row); - - $mysql->close(); -?> ---EXPECT-- -array(1) { - [0]=> - string(4) "test" -} diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt deleted file mode 100644 index 5f923ccf34..0000000000 --- a/ext/mysqli/tests/050.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -non freed statement test ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /************************ - * non freed stamement - ************************/ - $link = mysqli_connect($host, $user, $passwd); - - $stmt = mysqli_prepare($link, "SELECT CURRENT_USER()"); - mysqli_execute($stmt); - - mysqli_close($link); - printf("Ok\n"); -?> ---EXPECT-- -Ok diff --git a/ext/mysqli/tests/051.phpt b/ext/mysqli/tests/051.phpt deleted file mode 100644 index ef378757f1..0000000000 --- a/ext/mysqli/tests/051.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -free statement after close ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /************************ - * free statement after close - ************************/ - $link = mysqli_connect($host, $user, $passwd); - - $stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()"); - mysqli_execute($stmt1); - - mysqli_close($link); - @mysqli_stmt_close($stmt1); - printf("Ok\n"); -?> ---EXPECT-- -Ok diff --git a/ext/mysqli/tests/052.phpt b/ext/mysqli/tests/052.phpt deleted file mode 100644 index 3fa5dc8f17..0000000000 --- a/ext/mysqli/tests/052.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -call statement after close ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /************************ - * statement call after close - ************************/ - $link = mysqli_connect($host, $user, $passwd); - - $stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()"); - - mysqli_close($link); - @mysqli_execute($stmt2); - @mysqli_stmt_close($stmt2); - printf("Ok\n"); -?> ---EXPECT-- -Ok diff --git a/ext/mysqli/tests/053.phpt b/ext/mysqli/tests/053.phpt deleted file mode 100644 index 99148c7e80..0000000000 --- a/ext/mysqli/tests/053.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -not freed resultset ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /************************ - * non freed resultset - ************************/ - $link = mysqli_connect($host, $user, $passwd); - - $result = mysqli_query($link, "SELECT CURRENT_USER()"); - mysqli_close($link); - printf("Ok\n"); - -?> ---EXPECT-- -Ok diff --git a/ext/mysqli/tests/054.phpt b/ext/mysqli/tests/054.phpt deleted file mode 100644 index 727b87ef8e..0000000000 --- a/ext/mysqli/tests/054.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -free resultset after close ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /************************ - * free resultset after close - ************************/ - $link = mysqli_connect($host, $user, $passwd); - - $result1 = mysqli_query($link, "SELECT CURRENT_USER()"); - mysqli_close($link); - mysqli_free_result($result1); - printf("Ok\n"); -?> ---EXPECT-- -Ok diff --git a/ext/mysqli/tests/055.phpt b/ext/mysqli/tests/055.phpt deleted file mode 100644 index e650dbcecd..0000000000 --- a/ext/mysqli/tests/055.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -free nothing ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /************************ - * don't free anything - ************************/ - $link = mysqli_connect($host, $user, $passwd); - - $result2 = mysqli_query($link, "SELECT CURRENT_USER()"); - $stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()"); - printf("Ok\n"); -?> ---EXPECT-- -Ok diff --git a/ext/mysqli/tests/056.phpt b/ext/mysqli/tests/056.phpt deleted file mode 100644 index cc5c32fc60..0000000000 --- a/ext/mysqli/tests/056.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -extend mysqli ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - class foobar extends mysqli { - function test () { - return ("I like MySQL 4.1"); - } - } - - $foo = new foobar(); - $foo->connect($host, $user, $passwd); - $foo->close(); - printf("%s\n", $foo->test()); -?> ---EXPECT-- -I like MySQL 4.1 diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt deleted file mode 100644 index a987c72381..0000000000 --- a/ext/mysqli/tests/057.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -mysqli_get_metadata ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_store_result"); - mysqli_query($link,"CREATE TABLE test_store_result (a int)"); - - mysqli_query($link, "INSERT INTO test_store_result VALUES (1),(2),(3)"); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"); - mysqli_execute($stmt); - - /* this should produce an out of sync error */ - if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) { - mysqli_free_result($result); - printf ("Query ok\n"); - } - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"); - mysqli_execute($stmt); - $result1 = mysqli_get_metadata($stmt); - mysqli_stmt_store_result($stmt); - - printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt)); - - /* this should show an error, cause results are not buffered */ - if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) { - $row = mysqli_fetch_row($result); - mysqli_free_result($result); - } - - - var_dump($row); - - mysqli_free_result($result1); - mysqli_stmt_close($stmt); - mysqli_close($link); -?> ---EXPECT-- -Rows: 3 -array(1) { - [0]=> - string(1) "1" -} diff --git a/ext/mysqli/tests/058.phpt b/ext/mysqli/tests/058.phpt deleted file mode 100644 index 7554d08f68..0000000000 --- a/ext/mysqli/tests/058.phpt +++ /dev/null @@ -1,57 +0,0 @@ ---TEST-- -multiple binds ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link,"DROP TABLE IF EXISTS mbind"); - mysqli_query($link,"CREATE TABLE mbind (a int, b varchar(10))"); - - $stmt = mysqli_prepare($link, "INSERT INTO mbind VALUES (?,?)"); - - mysqli_bind_param($stmt, "is", $a, $b); - - $a = 1; - $b = "foo"; - - mysqli_execute($stmt); - - mysqli_bind_param($stmt, "is", $c, $d); - - $c = 2; - $d = "bar"; - - mysqli_execute($stmt); - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM mbind"); - mysqli_execute($stmt); - - mysqli_bind_result($stmt, $e, $f); - mysqli_fetch($stmt); - - mysqli_bind_result($stmt, $g, $h); - mysqli_fetch($stmt); - - var_dump((array($e,$f,$g,$h))); - - mysqli_close($link); -?> ---EXPECT-- -array(4) { - [0]=> - int(1) - [1]=> - string(3) "foo" - [2]=> - int(2) - [3]=> - string(3) "bar" -} diff --git a/ext/mysqli/tests/059.phpt b/ext/mysqli/tests/059.phpt deleted file mode 100644 index 0bc8a62bbf..0000000000 --- a/ext/mysqli/tests/059.phpt +++ /dev/null @@ -1,41 +0,0 @@ ---TEST-- -sqlmode + bind ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - - mysqli_query($link, "SET SQL_MODE='PIPES_AS_CONCAT'"); - - mysqli_query($link,"DROP TABLE IF EXISTS mbind"); - mysqli_query($link,"CREATE TABLE mbind (b varchar(25))"); - - $stmt = mysqli_prepare($link, "INSERT INTO mbind VALUES (?||?)"); - - mysqli_bind_param($stmt, "ss", $a, $b); - - $a = "foo"; - $b = "bar"; - - mysqli_execute($stmt); - - mysqli_stmt_close($stmt); - - $stmt = mysqli_prepare($link, "SELECT * FROM mbind"); - mysqli_execute($stmt); - - mysqli_bind_result($stmt, $e); - mysqli_fetch($stmt); - - var_dump($e); - - mysqli_close($link); -?> ---EXPECT-- -string(6) "foobar" diff --git a/ext/mysqli/tests/060.phpt b/ext/mysqli/tests/060.phpt deleted file mode 100644 index ba6c231c57..0000000000 --- a/ext/mysqli/tests/060.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -mysqli_fetch_object with classes ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - class test_class { - function __construct($arg1, $arg2) { - echo __METHOD__ . "($arg1,$arg2)\n"; - } - } - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - mysqli_query($link,"DROP TABLE IF EXISTS test_fetch"); - mysqli_query($link,"CREATE TABLE test_fetch(c1 smallint unsigned, - c2 smallint unsigned, - c3 smallint, - c4 smallint, - c5 smallint, - c6 smallint unsigned, - c7 smallint)"); - - mysqli_query($link, "INSERT INTO test_fetch VALUES ( -23, 35999, NULL, -500, -9999999, -0, 0)"); - - $result = mysqli_query($link, "SELECT * FROM test_bind_fetch"); - $test = mysqli_fetch_object($result, 'test_class', array(1, 2)); - mysqli_free_result($result); - - var_dump($test); - - mysqli_close($link); - - echo "Done\n"; -?> ---EXPECTF-- -test_class::__construct(1,2) -object(test_class)#%d (7) { - ["c1"]=> - string(1) "0" - ["c2"]=> - string(5) "35999" - ["c3"]=> - NULL - ["c4"]=> - string(4) "-500" - ["c5"]=> - string(6) "-32768" - ["c6"]=> - string(1) "0" - ["c7"]=> - string(1) "0" -} -Done diff --git a/ext/mysqli/tests/061.phpt b/ext/mysqli/tests/061.phpt deleted file mode 100644 index c7a217f274..0000000000 --- a/ext/mysqli/tests/061.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -local infile handler ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - function my_read($fp, &$buffer, $buflen, &$error) { - $buffer = strrev(fread($fp, $buflen)); - return(strlen($buffer)); - } - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd, "test"); - - /* create temporary file */ - $filename = dirname(__FILE__) . "061.csv"; - $fp = fopen($filename, "w"); - fwrite($fp, "foo;bar"); - fclose($fp); - - mysqli_query($link,"DROP TABLE IF EXISTS t_061"); - mysqli_query($link,"CREATE TABLE t_061 (c1 varchar(10), c2 varchar(10))"); - - mysqli_query($link, "LOAD DATA LOCAL INFILE '{$filename}' INTO TABLE t_061 FIELDS TERMINATED BY ';'"); - - mysqli_set_local_infile_handler($link, "my_read"); - mysqli_query($link, "LOAD DATA LOCAL INFILE '{$filename}' INTO TABLE t_061 FIELDS TERMINATED BY ';'"); - - if ($result = mysqli_query($link, "SELECT c1,c2 FROM t_061")) { - while (($row = mysqli_fetch_row($result))) { - printf("%s-%s\n", $row[0], $row[1]); - } - mysqli_free_result($result); - } - - mysqli_close($link); - unlink($filename); -?> ---EXPECT-- -foo-bar -rab-oof diff --git a/ext/mysqli/tests/062.phpt b/ext/mysqli/tests/062.phpt deleted file mode 100644 index 962abce162..0000000000 --- a/ext/mysqli/tests/062.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -resultset constructor ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd); - - $mysql->real_query("SELECT 'foo' FROM DUAL"); - - $myresult = new mysqli_result($mysql); - - $row = $myresult->fetch_row(); - $myresult->close(); - $mysql->close(); - - var_dump($row); -?> ---EXPECT-- -array(1) { - [0]=> - string(3) "foo" -} diff --git a/ext/mysqli/tests/063.phpt b/ext/mysqli/tests/063.phpt deleted file mode 100644 index 9dd01629aa..0000000000 --- a/ext/mysqli/tests/063.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -resultset constructor ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd); - - $stmt = new mysqli_stmt($mysql, "SELECT 'foo' FROM DUAL"); - $stmt->execute(); - $stmt->bind_result($foo); - $stmt->fetch(); - $stmt->close(); - $mysql->close(); - - var_dump($foo); -?> ---EXPECT-- -string(3) "foo" diff --git a/ext/mysqli/tests/064.phpt b/ext/mysqli/tests/064.phpt deleted file mode 100644 index e6df1e4505..0000000000 --- a/ext/mysqli/tests/064.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -NULL binding ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd); - - $stmt = new mysqli_stmt($mysql, "SELECT NULL FROM DUAL"); - $stmt->execute(); - $stmt->bind_result($foo); - $stmt->fetch(); - $stmt->close(); - $mysql->close(); - - var_dump($foo); -?> ---EXPECT-- -NULL diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt deleted file mode 100644 index 09ee886ec5..0000000000 --- a/ext/mysqli/tests/065.phpt +++ /dev/null @@ -1,41 +0,0 @@ ---TEST-- -set character set ---SKIPIF-- -<?php -require_once('skipif.inc'); -if (!function_exists('mysqli_set_charset')) { - die('skip mysqli_set_charset() not available'); -} -?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd); - mysqli_query($mysql, "SET sql_mode=''"); - - $esc_str = chr(0xbf) . chr(0x5c); - - if ($mysql->set_charset("latin1")) { - /* 5C should be escaped */ - $len[0] = strlen($mysql->real_escape_string($esc_str)); - $charset[0] = $mysql->client_encoding(); - } - - if ($mysql->set_charset("gbk")) { - /* nothing should be escaped, it's a valid gbk character */ - $len[1] = strlen($mysql->real_escape_string($esc_str)); - $charset[1] = $mysql->client_encoding(); - } - - $mysql->close(); - var_dump($len[0]); - var_dump($len[1]); - var_dump($charset[0]); - var_dump($charset[1]); -?> ---EXPECT-- -int(3) -int(2) -string(6) "latin1" -string(3) "gbk" diff --git a/ext/mysqli/tests/066.phpt b/ext/mysqli/tests/066.phpt deleted file mode 100644 index 01434f8d3f..0000000000 --- a/ext/mysqli/tests/066.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -function test: mysqli_warning object ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - /*** test mysqli_connect 127.0.0.1 ***/ - $mysql = new mysqli($host, $user, $passwd, "test"); - - $mysql->query("DROP TABLE IF EXISTS test_warnings"); - - $mysql->query("CREATE TABLE test_warnings (a int not null)"); - - $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)"); - - if (($warning = new mysqli_warning($mysql))) { - do { - printf("Warning\n"); - } while ($warning->next()); - } - - $mysql->close(); -?> ---EXPECT-- -Warning diff --git a/ext/mysqli/tests/067.phpt b/ext/mysqli/tests/067.phpt deleted file mode 100644 index d58d24cfee..0000000000 --- a/ext/mysqli/tests/067.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -function test: nested selects (cursors) ---SKIPIF-- -<?php - require_once('skipif.inc'); - /* skip cursor test for versions < 50004 */ - if (mysqli_get_client_version() < 50009) { - die("skip Client library doesn't support cursors"); - } -?> ---FILE-- -<?php - - function open_cursor($mysql, $query) { - $stmt = $mysql->prepare($query); - $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); - return $stmt; - } - - include "connect.inc"; - $a = array(); - - /*** test mysqli_connect 127.0.0.1 ***/ - $mysql = new mysqli($host, $user, $passwd, "test"); - - for ($i=0;$i < 3; $i++) { - $mysql->query("DROP TABLE IF EXISTS cursor$i"); - $mysql->query("CREATE TABLE cursor$i (a int not null)"); - $mysql->query("INSERT INTO cursor$i VALUES (1),(2),(3),(4),(5),(6)"); - $stmt[$i] = open_cursor($mysql, "SELECT a FROM cursor$i"); - $stmt[$i]->execute(); - $stmt[$i]->bind_result($a[$i]); - } - - - $cnt = 0; - while ($stmt[0]->fetch()) { - $stmt[1]->fetch(); - $stmt[2]->fetch(); - $cnt += $a[0] + $a[1] + $a[2]; - } - - for ($i=0; $i < 3; $i++) { - $stmt[$i]->close(); - } - - $mysql->close(); - var_dump($cnt); -?> ---EXPECT-- -int(63) diff --git a/ext/mysqli/tests/068.phpt b/ext/mysqli/tests/068.phpt deleted file mode 100644 index ab407c1ad8..0000000000 --- a/ext/mysqli/tests/068.phpt +++ /dev/null @@ -1,33 +0,0 @@ ---TEST-- -mysqli_autocommit() tests ---SKIPIF-- -<?php - require_once('skipif.inc'); -?> ---FILE-- -<?php - -include "connect.inc"; - -$mysqli = new mysqli($host, $user, $passwd, "test"); - -var_dump($mysqli->autocommit(false)); -$result = $mysqli->query("SELECT @@autocommit"); -var_dump($result->fetch_row()); - -var_dump($mysqli->autocommit(true)); -$result = $mysqli->query("SELECT @@autocommit"); -var_dump($result->fetch_row()); - -?> ---EXPECT-- -bool(true) -array(1) { - [0]=> - string(1) "0" -} -bool(true) -array(1) { - [0]=> - string(1) "1" -} diff --git a/ext/mysqli/tests/071.phpt b/ext/mysqli/tests/071.phpt deleted file mode 100644 index 75ff3e850d..0000000000 --- a/ext/mysqli/tests/071.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -mysqli thread_id & kill ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd, "test"); - - var_dump($mysql->ping()); - - var_dump($mysql->kill($mysql->thread_id)); - - var_dump($mysql->ping()); - - $mysql->close(); - - $mysql = new mysqli($host, $user, $passwd, "test"); - - var_dump(mysqli_ping($mysql)); - - var_dump(mysqli_kill($mysql, mysqli_thread_id($mysql))); - - var_dump(mysqli_ping($mysql)); - - $mysql->close(); -?> ---EXPECT-- -bool(true) -bool(true) -bool(false) -bool(true) -bool(true) -bool(false) diff --git a/ext/mysqli/tests/072.phpt b/ext/mysqli/tests/072.phpt deleted file mode 100644 index 8c85175ea2..0000000000 --- a/ext/mysqli/tests/072.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -mysqli warning_count, get_warnings ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php die('skip mysqli_warning class not functional yet?'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd, "test"); - - $mysql->query("DROP TABLE IF EXISTS not_exists"); - - var_dump($mysql->warning_count); - - $w = $mysql->get_warnings(); - - var_dump($w->errno); - var_dump($w->message); -# var_dump($w->sqlstate); - - $mysql->close(); -?> ---EXPECT-- -1 -1051 -Unknown table 'not_exists'
\ No newline at end of file diff --git a/ext/mysqli/tests/073.phpt b/ext/mysqli/tests/073.phpt deleted file mode 100644 index 5a017a2cb4..0000000000 --- a/ext/mysqli/tests/073.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -mysqli_driver properties ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - var_dump( $driver->embedded); - var_dump( $driver->client_version); - var_dump( $driver->client_info); - var_dump( $driver->driver_version); - var_dump( $driver->reconnect); - var_dump( $driver->report_mode); - -?> ---EXPECTF-- -bool(%s) -int(%d) -string(%d) "%s" -int(%d) -bool(%s) -int(%d) diff --git a/ext/mysqli/tests/bug28817.phpt b/ext/mysqli/tests/bug28817.phpt deleted file mode 100644 index 0cc8b13612..0000000000 --- a/ext/mysqli/tests/bug28817.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Bug #28817 testcase (properties) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - class my_mysql extends mysqli { - public $p_test; - - function __construct() { - $this->p_test[] = "foo"; - $this->p_test[] = "bar"; - } - } - - - $mysql = new my_mysql(); - - var_dump($mysql->p_test); - @var_dump($mysql->errno); - - $mysql->connect($host, $user, $passwd); - $mysql->select_db("nonexistingdb"); - - var_dump($mysql->errno > 0); - - $mysql->close(); -?> ---EXPECTF-- -array(2) { - [0]=> - string(3) "foo" - [1]=> - string(3) "bar" -} -NULL -bool(true) diff --git a/ext/mysqli/tests/bug29311.phpt b/ext/mysqli/tests/bug29311.phpt deleted file mode 100644 index b50de178b2..0000000000 --- a/ext/mysqli/tests/bug29311.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -constructor test ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - /* class 1 calls parent constructor */ - class mysql1 extends mysqli { - function __construct() { - global $host, $user, $passwd; - parent::__construct($host, $user, $passwd, "test"); - } - } - - /* class 2 has an own constructor */ - class mysql2 extends mysqli { - - function __construct() { - global $host, $user, $passwd; - $this->connect($host, $user, $passwd, "test"); - } - } - - /* class 3 has no constructor */ - class mysql3 extends mysqli { - - } - - $foo[0] = new mysql1(); - $foo[1] = new mysql2(); - $foo[2] = new mysql3($host, $user, $passwd, "test"); - - - for ($i=0; $i < 3; $i++) { - if (($result = $foo[$i]->query("SELECT DATABASE()"))) { - $row = $result->fetch_row(); - printf("%d: %s\n", $i, $row[0]); - $result->close(); - } - $foo[$i]->close(); - } -?> ---EXPECTF-- -0: test -1: test -2: test diff --git a/ext/mysqli/tests/bug30967.phpt b/ext/mysqli/tests/bug30967.phpt deleted file mode 100644 index 0a82d0d43c..0000000000 --- a/ext/mysqli/tests/bug30967.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Bug #30967 testcase (properties) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - class mysql1 extends mysqli { - } - - class mysql2 extends mysql1 { - } - - $mysql = new mysql2($host, $user, $passwd, "test"); - - $mysql->query("THIS DOES NOT WORK"); - printf("%d\n", $mysql->errno); - - $mysql->close(); -?> ---EXPECTF-- -1064 diff --git a/ext/mysqli/tests/bug31141.phpt b/ext/mysqli/tests/bug31141.phpt deleted file mode 100644 index acad79f1f9..0000000000 --- a/ext/mysqli/tests/bug31141.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -Bug #31141 testcase (properties) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -class Test extends mysqli -{ - public $test = array(); - - function foo() - { - $ar_test = array("foo", "bar"); - $this->test = &$ar_test; - } -} - -$my_test = new Test; -$my_test->foo(); -var_dump($my_test->test); -?> ---EXPECTF-- -array(2) { - [0]=> - string(3) "foo" - [1]=> - string(3) "bar" -} diff --git a/ext/mysqli/tests/bug31668.phpt b/ext/mysqli/tests/bug31668.phpt deleted file mode 100644 index b813096a2a..0000000000 --- a/ext/mysqli/tests/bug31668.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -Bug #31668 multi_query works exactly every other time (multi_query was global, now per connection) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd, "test"); - $mysql->multi_query('SELECT 1;SELECT 2'); - do { - $res = $mysql->store_result(); - if ($mysql->errno == 0) { - while ($arr = $res->fetch_assoc()) { - var_dump($arr); - } - $res->free(); - } - } while ($mysql->next_result()); - var_dump($mysql->error, __LINE__); - $mysql->close(); - - $mysql = new mysqli($host, $user, $passwd, "test"); - $mysql->multi_query('SELECT 1;SELECT 2'); - do { - $res = $mysql->store_result(); - if ($mysql->errno == 0) { - while ($arr = $res->fetch_assoc()) { - var_dump($arr); - } - $res->free(); - } - } while ($mysql->next_result()); - var_dump($mysql->error, __LINE__); -?> ---EXPECTF-- -array(1) { - [1]=> - string(1) "1" -} -array(1) { - [2]=> - string(1) "2" -} -string(0) "" -int(%d) -array(1) { - [1]=> - string(1) "1" -} -array(1) { - [2]=> - string(1) "2" -} -string(0) "" -int(%d) diff --git a/ext/mysqli/tests/bug32405.phpt b/ext/mysqli/tests/bug32405.phpt deleted file mode 100644 index f805dc7982..0000000000 --- a/ext/mysqli/tests/bug32405.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -Bug #32405 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include ("connect.inc"); - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - mysqli_select_db($link, "test"); - mysqli_query($link, "SET sql_mode=''"); - - /* two fields are needed. the problem does not occur with 1 field only selected. */ - $link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))"); - $link->query('INSERT INTO test_users VALUES (NULL, "user1"), (NULL, "user2"), (NULL, "user3"), (NULL, "user4")'); - - - if ($stmt = $link->prepare("SELECT SQL_NO_CACHE user_id, login FROM test_users")) { - $stmt->execute(); - $stmt->bind_result($col1, $col2); - while ($stmt->fetch()) { - var_dump($col1, $col2); - } - $stmt->close(); - } - - mysqli_query($link,"DROP TABLE test_users"); - mysqli_close($link); -?> ---EXPECT-- -int(1) -string(5) "user1" -int(2) -string(5) "user2" -int(3) -string(5) "user3" -int(4) -string(5) "user4" diff --git a/ext/mysqli/tests/bug33090.phpt b/ext/mysqli/tests/bug33090.phpt deleted file mode 100644 index 5c1cba961e..0000000000 --- a/ext/mysqli/tests/bug33090.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Bug #33090 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include ("connect.inc"); - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - mysqli_select_db($link, "test"); - - if (!($link->prepare("this makes no sense"))) { - printf("%d\n", $link->errno); - printf("%s\n", $link->sqlstate); - } - $link->close(); -?> ---EXPECT-- -1064 -42000 diff --git a/ext/mysqli/tests/bug33263.phpt b/ext/mysqli/tests/bug33263.phpt deleted file mode 100644 index 8ccb1e7e53..0000000000 --- a/ext/mysqli/tests/bug33263.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -bug #33263 (mysqli_real_connect in __construct) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> -<?php require_once('skipifemb.inc'); ?> ---FILE-- -<?php - - include "connect.inc"; - - class test extends mysqli - { - public function __construct($host, $user, $passwd, $db) { - parent::init(); - parent::real_connect($host, $user, $passwd, $db); - } - } - - $mysql = new test($host, $user, $passwd, "test"); - - $stmt = $mysql->prepare("SELECT DATABASE()"); - $stmt->execute(); - $stmt->bind_result($db); - $stmt->fetch(); - $stmt->close(); - - var_dump($db); - - $mysql->close(); -?> ---EXPECT-- -string(4) "test" diff --git a/ext/mysqli/tests/bug33491.phpt b/ext/mysqli/tests/bug33491.phpt deleted file mode 100644 index 067e489aae..0000000000 --- a/ext/mysqli/tests/bug33491.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Bug #33491 (extended mysqli class crashes when result is not object) ---INI-- -error_reporting=4095 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -class DB extends mysqli -{ - public function query_single($query) { - $result = parent::query($query); - $result->fetch_row(); // <- Here be crash - } -} - -require_once dirname(__FILE__)."/connect.inc"; - -// Segfault when using the DB class which extends mysqli -$DB = new DB($host, $user, $passwd, ''); -$DB->query_single('SELECT DATE()'); - -?> ---EXPECTF-- -Fatal error: Call to a member function fetch_row() on a non-object in %sbug33491.php on line %d diff --git a/ext/mysqli/tests/bug34785.phpt b/ext/mysqli/tests/bug34785.phpt deleted file mode 100644 index a2b9f22881..0000000000 --- a/ext/mysqli/tests/bug34785.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Bug #32405 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include ("connect.inc"); - - class my_stmt extends mysqli_stmt - { - public function __construct($link, $query) { - parent::__construct($link, $query); - } - } - - class my_result extends mysqli_result - { - public function __construct($link, $query) { - parent::__construct($link, $query); - } - } - - /*** test mysqli_connect 127.0.0.1 ***/ - $link = mysqli_connect($host, $user, $passwd); - mysqli_query($link, "SET sql_mode=''"); - - $stmt = new my_stmt($link, "SELECT 'foo' FROM DUAL"); - - $stmt->execute(); - $stmt->bind_result($var); - $stmt->fetch(); - - $stmt->close(); - var_dump($var); - - mysqli_real_query($link, "SELECT 'bar' FROM DUAL"); - $result = new my_result($link, MYSQLI_STORE_RESULT); - $row = $result->fetch_row(); - $result->close(); - - var_dump($row[0]); - - mysqli_close($link); -?> ---EXPECT-- -string(3) "foo" -string(3) "bar" diff --git a/ext/mysqli/tests/bug34810.phpt b/ext/mysqli/tests/bug34810.phpt deleted file mode 100644 index 0b8a799a84..0000000000 --- a/ext/mysqli/tests/bug34810.phpt +++ /dev/null @@ -1,39 +0,0 @@ ---TEST-- -bug #34810 (mysqli::init() and others use wrong $this pointer without checks) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -class DbConnection { - public function connect() { - include "connect.inc"; - - $link = mysqli_connect($host, $user, $passwd); - var_dump($link); - - $link = mysqli_init(); - var_dump($link); - - $mysql = new mysqli($host, $user, $passwd, "test"); - $mysql->query("DROP TABLE IF EXISTS test_warnings"); - $mysql->query("CREATE TABLE test_warnings (a int not null)"); - $mysql->query("SET sql_mode=''"); - $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)"); - var_dump(mysqli_warning::__construct($mysql)); - } -} - -$db = new DbConnection(); -$db->connect(); - -echo "Done\n"; -?> ---EXPECTF-- -object(mysqli)#%d (0) { -} -object(mysqli)#%d (0) { -} -object(mysqli_warning)#%d (0) { -} -Done diff --git a/ext/mysqli/tests/bug35103.phpt b/ext/mysqli/tests/bug35103.phpt deleted file mode 100644 index b6118b9b2b..0000000000 --- a/ext/mysqli/tests/bug35103.phpt +++ /dev/null @@ -1,68 +0,0 @@ ---TEST-- -bug #35103 Bad handling of unsigned bigint ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -$drop = <<<EOSQL -DROP TABLE test_bint; -DROP TABLE test_buint; -EOSQL; - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd, "test"); - $mysql->query("DROP TABLE IF EXISTS test_bint"); - $mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM"); - $mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)"); - - $mysql->query("DROP TABLE IF EXISTS test_buint"); - $mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)"); - $mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)"); - - $stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a"); - $stmt->bind_result($v); - $stmt->execute(); - $i=0; - echo "BIG INT SIGNED, TEST\n"; - while ($i++ < 8) { - $stmt->fetch(); - echo $v, "\n"; - } - $stmt->close(); - - echo str_repeat("-", 20), "\n"; - - $stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a"); - $stmt->bind_result($v2); - $stmt->execute(); - $j=0; - echo "BIG INT UNSIGNED TEST\n"; - while ($j++ < 6) { - $stmt->fetch(); - echo $v2, "\n"; - } - $stmt->close(); - - $mysql->multi_query($drop); - - $mysql->close(); -?> ---EXPECT-- -BIG INT SIGNED, TEST --9223372036854775808 --2147483649 --2147483648 --2147483647 -2147483647 -2147483648 -2147483649 -9223372036854775807 --------------------- -BIG INT UNSIGNED TEST -2147483647 -2147483649 -4294967295 -9223372036854775807 -9223372036854775808 -18446744073709551615 diff --git a/ext/mysqli/tests/bug35517.phpt b/ext/mysqli/tests/bug35517.phpt deleted file mode 100644 index eb1b543463..0000000000 --- a/ext/mysqli/tests/bug35517.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Bug #35517 mysqli_stmt_fetch returns NULL ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd, "test"); - - $mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)"); - $mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)"); - - $stmt = $mysql->prepare("SELECT id FROM temp"); - $stmt->execute(); - $stmt->bind_result($id); - while ($stmt->fetch()) { - var_dump($id); - } - $stmt->close(); - - $mysql->query("DROP TABLE temp"); - $mysql->close(); -?> ---EXPECTF-- -string(10) "3000000897" -string(10) "3800001532" -string(10) "3900002281" -string(10) "3100059612" diff --git a/ext/mysqli/tests/bug35759.phpt b/ext/mysqli/tests/bug35759.phpt deleted file mode 100644 index 5f67a76247..0000000000 --- a/ext/mysqli/tests/bug35759.phpt +++ /dev/null @@ -1,44 +0,0 @@ ---TEST-- -bug #35759 : mysqli_stmt_bind_result() makes huge allocation when column empty ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -$sql=<<<EOSQL -CREATE TABLE blobby ( - a1 MEDIUMBLOB NOT NULL, - - -EOSQL; - include "connect.inc"; - $col_num= 1000; - - $mysql = new mysqli($host, $user, $passwd, "test"); - $mysql->query("DROP TABLE IF EXISTS blobby"); - $create = "CREATE TABLE blobby (a0 MEDIUMBLOB NOT NULL DEFAULT ''"; - $i= 0; - while (++$i < $col_num) { - $create .= ", a$i MEDIUMBLOB NOT NULL DEFAULT ''"; - } - $create .= ")"; - - $mysql->query($create); - $mysql->query("INSERT INTO blobby (a0) VALUES ('')"); - - $stmt = $mysql->prepare("SELECT * FROM blobby"); - $stmt->execute(); - $stmt->store_result(); - $params= array_pad(array(), $col_num, ""); - call_user_func_array(array($stmt, "bind_result"), $params); - $stmt->fetch(); - - $stmt->close(); - - $mysql->query("DROP TABLE blobby"); - - $mysql->close(); - echo "OK\n"; -?> ---EXPECT-- -OK diff --git a/ext/mysqli/tests/bug36420.phpt b/ext/mysqli/tests/bug36420.phpt deleted file mode 100644 index d35485e7fd..0000000000 --- a/ext/mysqli/tests/bug36420.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -bug #36420 (segfault when access result->num_rows after calling result->close()) ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - -include "connect.inc"; -$mysqli = mysqli_connect($host, $user, $passwd); - -$result = $mysqli->query('select 1'); - -$result->close(); -echo $result->num_rows; - -$mysqli->close(); -echo $result->num_rows; - -echo "Done\n"; -?> ---EXPECTF-- -Warning: main(): Couldn't fetch mysqli_result in %s on line %d - -Warning: main(): Couldn't fetch mysqli_result in %s on line %d -Done diff --git a/ext/mysqli/tests/bug36745.phpt b/ext/mysqli/tests/bug36745.phpt deleted file mode 100644 index 868015c450..0000000000 --- a/ext/mysqli/tests/bug36745.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -bug #36745 : LOAD DATA LOCAL INFILE doesn't return correct error message ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include ("connect.inc"); - - /*** test mysqli_connect 127.0.0.1 ***/ - $mysql = mysqli_connect($host, $user, $passwd, "test"); - - $mysql->query("DROP TABLE IF EXISTS litest"); - $mysql->query("CREATE TABLE litest (a VARCHAR(20))"); - - $mysql->query("LOAD DATA LOCAL INFILE 'filenotfound' INTO TABLE litest"); - var_dump($mysql->error); - - $mysql->close(); - printf("Done"); -?> ---EXPECTF-- -string(%d) "%s" -Done diff --git a/ext/mysqli/tests/bug36802.phpt b/ext/mysqli/tests/bug36802.phpt deleted file mode 100644 index 99f8633301..0000000000 --- a/ext/mysqli/tests/bug36802.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -bug #36802 : crashes with mysql_init ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - - class my_mysqli extends mysqli { - function __construct() - { - } - } - - include "connect.inc"; - - - $mysql = mysqli_init(); - - /* following operations should not work */ - if (method_exists($mysql, 'set_charset')) { - $x[0] = @$mysql->set_charset('utf8'); - } else { - $x[0] = NULL; - } - $x[1] = @$mysql->query("SELECT 'foo' FROM DUAL"); - - /* following operations should work */ - $x[2] = ($mysql->client_version > 0); - $x[3] = $mysql->errno; - $mysql->close(); - - - - var_dump($x); -?> ---EXPECT-- -array(4) { - [0]=> - NULL - [1]=> - NULL - [2]=> - bool(true) - [3]=> - int(0) -} diff --git a/ext/mysqli/tests/bug36949.phpt b/ext/mysqli/tests/bug36949.phpt deleted file mode 100644 index fb57df4864..0000000000 --- a/ext/mysqli/tests/bug36949.phpt +++ /dev/null @@ -1,50 +0,0 @@ ---TEST-- -bug #36949 ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -include "connect.inc"; - -class A { - - private $mysqli; - - public function __construct() { - global $user, $host, $passwd; - $this->mysqli = new mysqli($host, $user, $passwd); - $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL"); - $row = $result->fetch_object(); - echo $row->my_time."<br>\n"; - $result->close(); - } - - public function __destruct() { - $this->mysqli->close(); - } -} - -class B { - - private $mysqli; - - public function __construct() { - global $user, $host, $passwd; - $this->mysqli = new mysqli($host, $user, $passwd); - $result = $this->mysqli->query("SELECT NOW() AS my_time FROM DUAL"); - $row = $result->fetch_object(); - echo $row->my_time."<br>\n"; - $result->close(); - } - - public function __destruct() { - $this->mysqli->close(); - } -} - -$A = new A(); -$B = new B(); -?> ---EXPECTF-- -%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d<br> -%d%d%d%d-%d%d-%d%d %d%d:%d%d:%d%d<br> diff --git a/ext/mysqli/tests/bug37090.phpt b/ext/mysqli/tests/bug37090.phpt deleted file mode 100644 index de6043d38a..0000000000 --- a/ext/mysqli/tests/bug37090.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -bug #37090: mysqli_set_charset return code ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php - include "connect.inc"; - - $mysql = new mysqli($host, $user, $passwd); - - $cs = array(); - $cs[] = $mysql->set_charset("latin5"); - $cs[] = $mysql->character_set_name(); - - $cs[] = $mysql->set_charset("utf8"); - $cs[] = $mysql->character_set_name(); - - $cs[] = $mysql->set_charset("notdefined"); - $cs[] = $mysql->character_set_name(); - - var_dump($cs); -?> ---EXPECT-- -array(6) { - [0]=> - bool(true) - [1]=> - string(6) "latin5" - [2]=> - bool(true) - [3]=> - string(4) "utf8" - [4]=> - bool(false) - [5]=> - string(4) "utf8" -} diff --git a/ext/mysqli/tests/bug38003.phpt b/ext/mysqli/tests/bug38003.phpt deleted file mode 100644 index af71f85f2c..0000000000 --- a/ext/mysqli/tests/bug38003.phpt +++ /dev/null @@ -1,20 +0,0 @@ ---TEST-- -Bug #38003 (in classes inherited from MySQLi it's possible to call private constructors from invalid context) ---SKIPIF-- -<?php if (!extension_loaded("mysqli")) print "skip"; ?> ---FILE-- -<?php - -class DB extends mysqli { - - private function __construct($hostname, $username, $password, $database) { - var_dump("DB::__construct() called"); - } -} - -$DB = new DB(); - -echo "Done\n"; -?> ---EXPECTF-- -Fatal error: Call to private DB::__construct() from invalid context in %s on line %d diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc deleted file mode 100644 index ea24ff89ae..0000000000 --- a/ext/mysqli/tests/connect.inc +++ /dev/null @@ -1,25 +0,0 @@ -<?php - - /* default values are localhost, root and empty password - Change the values if you use another configuration */ - $driver = new mysqli_driver; - - if (!$driver->embedded) { - $host = "localhost"; - $user = "root"; - $passwd = ""; - } else { - $path = dirname(__FILE__); - $host = ":embedded"; - $user = $passwd = NULL; - $args = array( - "--datadir=$path", - "--innodb_data_home_dir=$path", - "--innodb_data_file_path=ibdata1:10M:autoextend", - "--log-error=$path/testrun.log", - "--init-connect='CREATE DATABASE IF NOT EXISTS test;'" - ); - $driver->embedded_server_start(TRUE, $args, NULL); - } - -?> diff --git a/ext/mysqli/tests/skipif.inc b/ext/mysqli/tests/skipif.inc deleted file mode 100644 index f471b5e126..0000000000 --- a/ext/mysqli/tests/skipif.inc +++ /dev/null @@ -1,10 +0,0 @@ -<?php -if (!extension_loaded('mysqli')){ - die('skip mysqli extension not available'); -} -include "connect.inc"; -$driver = new mysqli_driver(); -if (!$driver->embedded && !@mysqli_connect($host, $user, $passwd, "", 3306)) { - die('skip could not connect to MySQL'); -} -?> diff --git a/ext/mysqli/tests/skipifemb.inc b/ext/mysqli/tests/skipifemb.inc deleted file mode 100644 index 298c7219a6..0000000000 --- a/ext/mysqli/tests/skipifemb.inc +++ /dev/null @@ -1,5 +0,0 @@ -<?php - $driver = new mysqli_driver(); - if ($driver->embedded) - die("skip test doesn't run with embedded server"); -?> diff --git a/ext/mysqli/tests/skipifnotemb.inc b/ext/mysqli/tests/skipifnotemb.inc deleted file mode 100644 index 8639130cbe..0000000000 --- a/ext/mysqli/tests/skipifnotemb.inc +++ /dev/null @@ -1,5 +0,0 @@ -<?php - $driver = new mysqli_driver(); - if (!$driver->embedded) - die("skip test for with embedded server only"); -?> |