georg Fri Jan 7 10:00:00 2005 EDT Added files: /php-src/ext/mysqli mysqli_driver.c mysqli_embedded.c mysqli_exception.c mysqli_warning.c /php-src/ext/mysqli/tests skipifemb.inc
Modified files: /php-src/ext/mysqli config.m4 mysqli.c mysqli_api.c mysqli_fe.c mysqli_nonapi.c mysqli_prop.c mysqli_report.c php_mysqli.h /php-src/ext/mysqli/tests 001.phpt 014.phpt 017.phpt 033.phpt 034.phpt 041.phpt 045.phpt 047.phpt 049.phpt 061.phpt connect.inc skipif.inc Log: Added new classes: mysqli_driver mysqli_warning mysqli_exception mysqli_sql_exception Improved embedded server support changed testsuite to work also with embedded server Made statement and resultset classes extendable minor fixes
http://cvs.php.net/diff.php/php-src/ext/mysqli/config.m4?r1=1.18&r2=1.19&ty=u Index: php-src/ext/mysqli/config.m4 diff -u php-src/ext/mysqli/config.m4:1.18 php-src/ext/mysqli/config.m4:1.19 --- php-src/ext/mysqli/config.m4:1.18 Thu Jul 22 03:24:55 2004 +++ php-src/ext/mysqli/config.m4 Fri Jan 7 09:59:59 2005 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.18 2004/07/22 07:24:55 georg Exp $ +dnl $Id: config.m4,v 1.19 2005/01/07 14:59:59 georg Exp $ dnl config.m4 for extension mysqli PHP_ARG_WITH(mysqli, for MySQLi support, @@ -54,6 +54,6 @@ $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, $ext_shared) + 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 http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli.c?r1=1.57&r2=1.58&ty=u Index: php-src/ext/mysqli/mysqli.c diff -u php-src/ext/mysqli/mysqli.c:1.57 php-src/ext/mysqli/mysqli.c:1.58 --- php-src/ext/mysqli/mysqli.c:1.57 Sun Dec 26 08:16:38 2004 +++ php-src/ext/mysqli/mysqli.c Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli.c,v 1.57 2004/12/26 13:16:38 georg Exp $ + $Id: mysqli.c,v 1.58 2005/01/07 14:59:59 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -37,9 +37,12 @@ ZEND_DECLARE_MODULE_GLOBALS(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; + extern void php_mysqli_connect(INTERNAL_FUNCTION_PARAMETERS); typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC); @@ -142,6 +145,10 @@ if (my_res && my_res->ptr) { mysql_free_result(my_res->ptr); } + } else if (intern->zo.ce == mysqli_warning_class_entry) { /* warning object */ + if (my_res && my_res->ptr) { + php_clear_warnings((MYSQLI_WARNING *)my_res->ptr); + } } my_efree(my_res); efree(object); @@ -282,7 +289,8 @@ mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC); if (obj->zo.ce != mysqli_link_class_entry && obj->zo.ce != mysqli_stmt_class_entry && - obj->zo.ce != mysqli_result_class_entry) { + obj->zo.ce != mysqli_result_class_entry && obj->zo.ce != mysqli_driver_class_entry && + obj->zo.ce != mysqli_warning_class_entry) { return obj->zo.ce->constructor; } else { static zend_internal_function f; @@ -300,6 +308,10 @@ 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_FN(mysqli_driver_construct); } return (union _zend_function*)&f; @@ -397,6 +409,11 @@ mysqli_globals->report_mode = 0; mysqli_globals->report_ht = 0; mysqli_globals->multi_query = 0; +#ifdef HAVE_EMBEDDED_MYSQLI + mysqli_globals->embedded = 1; +#else + mysqli_globals->embedded = 0; +#endif } /* }}} */ @@ -404,9 +421,8 @@ */ PHP_MINIT_FUNCTION(mysqli) { - zend_class_entry *ce; + zend_class_entry *ce,cex; zend_object_handlers *std_hnd = zend_get_std_object_handlers(); - ZEND_INIT_MODULE_GLOBALS(mysqli, php_mysqli_init_globals, NULL); REGISTER_INI_ENTRIES(); @@ -420,13 +436,37 @@ zend_hash_init(&classes, 0, NULL, NULL, 1); - REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods); + 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(), 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; + 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; + 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); + ce->ce_flags |= ZEND_ACC_FINAL; + 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); @@ -538,9 +578,11 @@ */ PHP_MSHUTDOWN_FUNCTION(mysqli) { - zend_hash_destroy(&mysqli_link_properties); +// 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(); @@ -708,6 +750,7 @@ 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) { + // php_std_error_handling(); return; } if (ZEND_NUM_ARGS() < (getThis() ? 1 : 2)) { @@ -723,17 +766,18 @@ } else { if (override_flags) { if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { + //php_std_error_handling(); 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) { + // php_std_error_handling(); return; } } } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result"); if (!(row = mysql_fetch_row(result))) { @@ -930,6 +974,7 @@ } /* }}} */ +/* {{{ int php_local_infile_read */ int php_local_infile_read(void *ptr, char *buf, uint buf_len) { mysqli_local_infile *data; @@ -1003,6 +1048,7 @@ efree(fp); return rc; } +/* }}} */ /* {{{ php_local_infile_error */ http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_api.c?r1=1.97&r2=1.98&ty=u Index: php-src/ext/mysqli/mysqli_api.c diff -u php-src/ext/mysqli/mysqli_api.c:1.97 php-src/ext/mysqli/mysqli_api.c:1.98 --- php-src/ext/mysqli/mysqli_api.c:1.97 Mon Dec 27 10:39:34 2004 +++ php-src/ext/mysqli/mysqli_api.c Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_api.c,v 1.97 2004/12/27 15:39:34 georg Exp $ + $Id: mysqli_api.c,v 1.98 2005/01/07 14:59:59 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -149,7 +149,7 @@ break; case 'b': /* Blob (send data) */ - bind[ofs].buffer_type = MYSQL_TYPE_VAR_STRING; + bind[ofs].buffer_type = MYSQL_TYPE_LONG_BLOB; bind[ofs].is_null = 0; bind[ofs].length = 0; break; @@ -182,7 +182,7 @@ 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 != MYSQLI_BIND_SEND_DATA) { + if (bind[i].buffer_type != MYSQL_TYPE_LONG_BLOB) { ZVAL_ADDREF(*args[i+start]); stmt->param.vars[i] = *args[i+start]; } else { @@ -564,6 +564,7 @@ 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); } @@ -837,7 +838,7 @@ MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result"); if (fieldnr < 0 || fieldnr >= mysql_num_fields(result)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Field offset is invalid for resultset"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Function cannot be used with MYSQL_USE_RESULT"); RETURN_FALSE; } @@ -1305,12 +1306,10 @@ if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,flags) == NULL) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); 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, + mysql->mysql->net.last_error); - if (!(MyG(report_mode) & MYSQLI_REPORT_ERROR)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->mysql)); - } RETURN_FALSE; } php_mysqli_set_error(mysql_errno(mysql->mysql), (char *)mysql_error(mysql->mysql) TSRMLS_CC); @@ -1422,39 +1421,6 @@ } /* }}} */ -#ifdef HAVE_EMBEDDED_MYSQLI -/* {{{ proto bool mysqli_server_init(void) - initialize embedded server */ -PHP_FUNCTION(mysqli_server_init) -{ - zval *server; - zval *groups; - - if (MyG(embedded)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Embedded server already initialized."); - RETURN_FALSE; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|aa", &server, &groups) == FAILURE) { - return; - } - - if (mysql_server_init(0, NULL, NULL)) { - RETURN_FALSE; - } - MyG(embedded) = 1; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void mysqli_server_end(void) -*/ -PHP_FUNCTION(mysqli_server_end) -{ - mysql_server_end(); -} -/* }}} */ -#endif /* {{{ proto mixed mysqli_stmt_affected_rows(object stmt) Return the number of rows affected in the last query for the given link */ http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_fe.c?r1=1.41&r2=1.42&ty=u Index: php-src/ext/mysqli/mysqli_fe.c diff -u php-src/ext/mysqli/mysqli_fe.c:1.41 php-src/ext/mysqli/mysqli_fe.c:1.42 --- php-src/ext/mysqli/mysqli_fe.c:1.41 Fri Jul 23 08:47:36 2004 +++ php-src/ext/mysqli/mysqli_fe.c Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_fe.c,v 1.41 2004/07/23 12:47:36 georg Exp $ + $Id: mysqli_fe.c,v 1.42 2005/01/07 14:59:59 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -65,11 +65,10 @@ PHP_FE(mysqli_disable_reads_from_master, NULL) PHP_FE(mysqli_disable_rpl_parse, NULL) PHP_FE(mysqli_dump_debug_info, NULL) -#ifdef HAVE_EMBEDDED_MYSQLI - PHP_FE(mysqli_embedded_connect, NULL) -#endif 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) @@ -132,10 +131,6 @@ PHP_FE(mysqli_stmt_reset, NULL) PHP_FE(mysqli_stmt_param_count, NULL) PHP_FE(mysqli_send_query, NULL) -#ifdef HAVE_EMBEDDED_MYSQLI - PHP_FE(mysqli_server_end, NULL) - PHP_FE(mysqli_server_init, NULL) -#endif PHP_FE(mysqli_slave_query, NULL) PHP_FE(mysqli_sqlstate, NULL) PHP_FE(mysqli_ssl_set, NULL) @@ -196,6 +191,7 @@ PHP_FALIAS(enable_rpl_parse,mysqli_enable_rpl_parse,NULL) 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_warning_construct, 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) @@ -265,6 +261,7 @@ 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_warning_construct, 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) http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_nonapi.c?r1=1.38&r2=1.39&ty=u Index: php-src/ext/mysqli/mysqli_nonapi.c diff -u php-src/ext/mysqli/mysqli_nonapi.c:1.38 php-src/ext/mysqli/mysqli_nonapi.c:1.39 --- php-src/ext/mysqli/mysqli_nonapi.c:1.38 Mon Nov 1 04:53:16 2004 +++ php-src/ext/mysqli/mysqli_nonapi.c Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_nonapi.c,v 1.38 2004/11/01 09:53:16 georg Exp $ + $Id: mysqli_nonapi.c,v 1.39 2005/01/07 14:59:59 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -74,15 +74,23 @@ RETURN_FALSE; } +#ifdef HAVE_EMBEDDED_MYSQLI + if (hostname && strlen(hostname)) { + unsigned int external=1; + mysql_options(mysql->mysql, MYSQL_OPT_USE_REMOTE_CONNECTION, (char *)&external); + } else { + mysql_options(mysql->mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, 0); + } +#endif + if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,CLIENT_MULTI_RESULTS) == NULL) { /* Save error messages */ - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); + php_mysqli_throw_sql_exception( mysql->mysql->net.sqlstate, mysql->mysql->net.last_errno TSRMLS_CC, + mysql->mysql->net.last_error); + php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC); - if (!(MyG(report_mode) & MYSQLI_REPORT_ERROR)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->mysql)); - } /* free mysql structure */ mysql_close(mysql->mysql); RETURN_FALSE; @@ -108,60 +116,6 @@ } /* }}} */ -#ifdef HAVE_EMBEDDED_MYSQLI -/* {{{ proto object mysqli_embedded_connect(void) - Open a connection to a embedded mysql server */ -PHP_FUNCTION(mysqli_embedded_connect) -{ - MY_MYSQL *mysql; - MYSQLI_RESOURCE *mysqli_resource; - zval *object = getThis(); - char *dbname = NULL; - int dblen = 0; - - if (!MyG(embedded)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Embedded server was not initialized."); - RETURN_FALSE; - } - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &dbname, &dblen) == FAILURE) { - return; - } - - mysql = (MY_MYSQL *) calloc(1, sizeof(MY_MYSQL)); - - if (!(mysql = mysql_init(NULL))) { - efree(mysql); - RETURN_FALSE; - } - - if (mysql_real_connect(mysql, NULL, NULL, NULL, dbname, 0, NULL, 0) == NULL) { - MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); - php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC); - - if (!(MyG(report_mode) & MYSQLI_REPORT_ERROR)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql->mysql)); - } - /* free mysql structure */ - mysql_close(mysql->mysql); - efree(mysql); - RETURN_FALSE; - } - - php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC); - - mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); - mysqli_resource->ptr = (void *)mysql; - - if (!object) { - MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); - } else { - ((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->ptr = mysqli_resource; - } -} -/* }}} */ -#endif - /* {{{ proto int mysqli_connect_errno(void) Returns the numerical value of the error message from last connect command */ PHP_FUNCTION(mysqli_connect_errno) @@ -278,6 +232,8 @@ 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, + mysql->mysql->net.last_error); RETURN_FALSE; } http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_prop.c?r1=1.18&r2=1.19&ty=u Index: php-src/ext/mysqli/mysqli_prop.c diff -u php-src/ext/mysqli/mysqli_prop.c:1.18 php-src/ext/mysqli/mysqli_prop.c:1.19 --- php-src/ext/mysqli/mysqli_prop.c:1.18 Wed Dec 29 06:46:13 2004 +++ php-src/ext/mysqli/mysqli_prop.c Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_prop.c,v 1.18 2004/12/29 11:46:13 georg Exp $ + $Id: mysqli_prop.c,v 1.19 2005/01/07 14:59:59 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -225,6 +225,7 @@ MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_error_read, mysql_stmt_error, MYSQLI_GET_STMT()); MYSQLI_MAP_PROPERTY_FUNC_STRING(stmt_sqlstate_read, mysql_stmt_sqlstate, MYSQLI_GET_STMT()); +/* }}} */ mysqli_property_entry mysqli_link_property_entries[] = { {"affected_rows", link_affected_rows_read, NULL}, {"client_info", link_client_info_read, NULL}, http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_report.c?r1=1.9&r2=1.10&ty=u Index: php-src/ext/mysqli/mysqli_report.c diff -u php-src/ext/mysqli/mysqli_report.c:1.9 php-src/ext/mysqli/mysqli_report.c:1.10 --- php-src/ext/mysqli/mysqli_report.c:1.9 Wed Jul 7 04:02:27 2004 +++ php-src/ext/mysqli/mysqli_report.c Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mysqli_report.c,v 1.9 2004/07/07 08:02:27 georg Exp $ + $Id: mysqli_report.c,v 1.10 2005/01/07 14:59:59 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -46,7 +46,7 @@ /* {{{ 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_error_docref(NULL TSRMLS_CC, E_WARNING, "Error (%s/%d): %s", sqlstate, errorno, error); + php_mysqli_throw_sql_exception(sqlstate, errorno TSRMLS_CC, error); } /* }}} */ @@ -61,7 +61,7 @@ } else { return; } - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s used in query/prepared statement %s", index, query); + php_mysqli_throw_sql_exception("00000", 0 TSRMLS_CC, "%s used in query/prepared statement %s", index, query); } /* }}} */ http://cvs.php.net/diff.php/php-src/ext/mysqli/php_mysqli.h?r1=1.41&r2=1.42&ty=u Index: php-src/ext/mysqli/php_mysqli.h diff -u php-src/ext/mysqli/php_mysqli.h:1.41 php-src/ext/mysqli/php_mysqli.h:1.42 --- php-src/ext/mysqli/php_mysqli.h:1.41 Sun Dec 26 08:16:38 2004 +++ php-src/ext/mysqli/php_mysqli.h Fri Jan 7 09:59:59 2005 @@ -15,7 +15,7 @@ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: php_mysqli.h,v 1.41 2004/12/26 13:16:38 georg Exp $ + $Id: php_mysqli.h,v 1.42 2005/01/07 14:59:59 georg Exp $ */ /* A little hack to prevent build break, when mysql is used together with @@ -31,6 +31,8 @@ #ifndef PHP_MYSQLI_H #define PHP_MYSQLI_H +#define MYSQLI_VERSION_ID 101008 + typedef struct { ulong buflen; char *val; @@ -68,6 +70,12 @@ void *info; /* additional buffer */ } MYSQLI_RESOURCE; +typedef struct { + MYSQL_RES *result; /* stored result set from SHOW WARNINGS */ + MYSQL_ROW row; + int warning_count; /* number of warnings */ +} MYSQLI_WARNING; + typedef struct _mysqli_object { zend_object zo; void *ptr; @@ -78,7 +86,7 @@ typedef struct _mysqli_property_entry { char *pname; int (*r_func)(mysqli_object *obj, zval **retval TSRMLS_DC); - int (*w_func)(mysqli_object *obj, zval **retval TSRMLS_DC); + int (*w_func)(mysqli_object *obj, zval *value TSRMLS_DC); } mysqli_property_entry; typedef struct { @@ -105,13 +113,20 @@ extern function_entry mysqli_link_methods[]; extern function_entry mysqli_stmt_methods[]; extern function_entry mysqli_result_methods[]; +extern function_entry mysqli_driver_methods[]; +extern function_entry mysqli_warning_methods[]; +extern 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); -void php_clear_mysql(MY_MYSQL *); +extern void php_clear_mysql(MY_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); @@ -120,14 +135,17 @@ 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, ...); 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; -zend_class_entry _mysqli_link_class_entry; -zend_class_entry _mysqli_stmt_class_entry; -zend_class_entry _mysqli_result_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); @@ -142,9 +160,10 @@ } #define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \ - INIT_CLASS_ENTRY(_##mysqli_entry,name,class_functions); \ - _##mysqli_entry.create_object = mysqli_objects_new; \ - mysqli_entry = zend_register_internal_class(&_##mysqli_entry TSRMLS_CC); \ + 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, __ce) \ @@ -210,7 +229,7 @@ { \ int i = 0; \ while (b[i].pname != NULL) { \ - mysqli_add_property(a, b[i].pname, (mysqli_read_t)b[i].r_func, NULL TSRMLS_CC); \ + mysqli_add_property(a, b[i].pname, (mysqli_read_t)b[i].r_func, (mysqli_write_t)b[i].w_func TSRMLS_CC); \ i++; \ }\ } @@ -241,9 +260,10 @@ /*** REPORT MODES ***/ #define MYSQLI_REPORT_OFF 0 -#define MYSQLI_REPORT_INDEX 1 -#define MYSQLI_REPORT_ERROR 2 -#define MYSQLI_REPORT_CLOSE 4 +#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) \ @@ -282,9 +302,6 @@ PHP_FUNCTION(mysqli_disable_reads_from_master); PHP_FUNCTION(mysqli_disable_rpl_parse); PHP_FUNCTION(mysqli_dump_debug_info); -#ifdef HAVE_EMBEDDED_MYSQLI -PHP_FUNCTION(mysqli_embedded_connect); -#endif PHP_FUNCTION(mysqli_enable_reads_from_master); PHP_FUNCTION(mysqli_enable_rpl_parse); PHP_FUNCTION(mysqli_errno); @@ -347,10 +364,8 @@ PHP_FUNCTION(mysqli_stmt_param_count); PHP_FUNCTION(mysqli_stmt_send_long_data); PHP_FUNCTION(mysqli_send_query); -#ifdef HAVE_EMBEDDED_MYSQLI -PHP_FUNCTION(mysqli_server_init); -PHP_FUNCTION(mysqli_server_end); -#endif +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); @@ -374,6 +389,8 @@ ZEND_FUNCTION(mysqli_stmt_construct); ZEND_FUNCTION(mysqli_result_construct); +ZEND_FUNCTION(mysqli_driver_construct); +ZEND_FUNCTION(mysqli_warning_construct); ZEND_BEGIN_MODULE_GLOBALS(mysqli) long default_link; @@ -385,14 +402,13 @@ 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; -#ifdef HAVE_EMBEDDED_MYSQLI unsigned int embedded; -#endif ZEND_END_MODULE_GLOBALS(mysqli) http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/001.phpt?r1=1.5&r2=1.6&ty=u Index: php-src/ext/mysqli/tests/001.phpt diff -u php-src/ext/mysqli/tests/001.phpt:1.5 php-src/ext/mysqli/tests/001.phpt:1.6 --- php-src/ext/mysqli/tests/001.phpt:1.5 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/001.phpt Fri Jan 7 09:59:59 2005 @@ -2,13 +2,14 @@ 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"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/014.phpt?r1=1.6&r2=1.7&ty=u Index: php-src/ext/mysqli/tests/014.phpt diff -u php-src/ext/mysqli/tests/014.phpt:1.6 php-src/ext/mysqli/tests/014.phpt:1.7 --- php-src/ext/mysqli/tests/014.phpt:1.6 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/014.phpt Fri Jan 7 09:59:59 2005 @@ -1,7 +1,7 @@ --TEST-- mysqli autocommit/commit/rollback --SKIPIF-- -<?php +<?php include "connect.inc"; $link = mysqli_connect($host, $user, $passwd); $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'"); http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/017.phpt?r1=1.6&r2=1.7&ty=u Index: php-src/ext/mysqli/tests/017.phpt diff -u php-src/ext/mysqli/tests/017.phpt:1.6 php-src/ext/mysqli/tests/017.phpt:1.7 --- php-src/ext/mysqli/tests/017.phpt:1.6 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/017.phpt Fri Jan 7 09:59:59 2005 @@ -2,6 +2,7 @@ mysqli fetch functions --SKIPIF-- <?php require_once('skipif.inc'); ?> +<?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/033.phpt?r1=1.3&r2=1.4&ty=u Index: php-src/ext/mysqli/tests/033.phpt diff -u php-src/ext/mysqli/tests/033.phpt:1.3 php-src/ext/mysqli/tests/033.phpt:1.4 --- php-src/ext/mysqli/tests/033.phpt:1.3 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/033.phpt Fri Jan 7 09:59:59 2005 @@ -2,6 +2,7 @@ function test: mysqli_get_host_info --SKIPIF-- <?php require_once('skipif.inc'); ?> +<?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/034.phpt?r1=1.3&r2=1.4&ty=u Index: php-src/ext/mysqli/tests/034.phpt diff -u php-src/ext/mysqli/tests/034.phpt:1.3 php-src/ext/mysqli/tests/034.phpt:1.4 --- php-src/ext/mysqli/tests/034.phpt:1.3 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/034.phpt Fri Jan 7 09:59:59 2005 @@ -2,6 +2,7 @@ function test: mysqli_get_proto_info --SKIPIF-- <?php require_once('skipif.inc'); ?> +<?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/041.phpt?r1=1.3&r2=1.4&ty=u Index: php-src/ext/mysqli/tests/041.phpt diff -u php-src/ext/mysqli/tests/041.phpt:1.3 php-src/ext/mysqli/tests/041.phpt:1.4 --- php-src/ext/mysqli/tests/041.phpt:1.3 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/041.phpt Fri Jan 7 09:59:59 2005 @@ -15,8 +15,8 @@ mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"); mysqli_query($link, "CREATE TABLE test_warnings (a int not null"); + mysqli_query($link, "INSERT INTO test_warnings VALUES (NULL)"); - mysqli_query($link, "INSERT INTO test_warnings VALUES (1),(2),(NULL)"); $num = mysqli_warning_count($link); var_dump($num); http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/045.phpt?r1=1.5&r2=1.6&ty=u Index: php-src/ext/mysqli/tests/045.phpt diff -u php-src/ext/mysqli/tests/045.phpt:1.5 php-src/ext/mysqli/tests/045.phpt:1.6 --- php-src/ext/mysqli/tests/045.phpt:1.5 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/045.phpt Fri Jan 7 09:59:59 2005 @@ -17,6 +17,7 @@ ?> --SKIPIF-- <?php require_once('skipif.inc'); ?> +<?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/047.phpt?r1=1.7&r2=1.8&ty=u Index: php-src/ext/mysqli/tests/047.phpt diff -u php-src/ext/mysqli/tests/047.phpt:1.7 php-src/ext/mysqli/tests/047.phpt:1.8 --- php-src/ext/mysqli/tests/047.phpt:1.7 Mon Dec 27 10:39:35 2004 +++ php-src/ext/mysqli/tests/047.phpt Fri Jan 7 09:59:59 2005 @@ -31,7 +31,7 @@ --EXPECTF-- array(2) { [0]=> - object(stdClass)#4 (11) { + object(stdClass)#5 (11) { ["name"]=> string(3) "foo" ["orgname"]=> @@ -56,7 +56,7 @@ int(0) } [1]=> - object(stdClass)#5 (11) { + object(stdClass)#6 (11) { ["name"]=> string(3) "bar" ["orgname"]=> http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/049.phpt?r1=1.3&r2=1.4&ty=u Index: php-src/ext/mysqli/tests/049.phpt diff -u php-src/ext/mysqli/tests/049.phpt:1.3 php-src/ext/mysqli/tests/049.phpt:1.4 --- php-src/ext/mysqli/tests/049.phpt:1.3 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/049.phpt Fri Jan 7 09:59:59 2005 @@ -2,6 +2,7 @@ mysql_fetch_row (OO-Style) --SKIPIF-- <?php require_once('skipif.inc'); ?> +<?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/061.phpt?r1=1.3&r2=1.4&ty=u Index: php-src/ext/mysqli/tests/061.phpt diff -u php-src/ext/mysqli/tests/061.phpt:1.3 php-src/ext/mysqli/tests/061.phpt:1.4 --- php-src/ext/mysqli/tests/061.phpt:1.3 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/061.phpt Fri Jan 7 09:59:59 2005 @@ -2,6 +2,7 @@ local infile handler --SKIPIF-- <?php require_once('skipif.inc'); ?> +<?php require_once('skipifemb.inc'); ?> --FILE-- <?php include "connect.inc"; http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/connect.inc?r1=1.1&r2=1.2&ty=u Index: php-src/ext/mysqli/tests/connect.inc diff -u php-src/ext/mysqli/tests/connect.inc:1.1 php-src/ext/mysqli/tests/connect.inc:1.2 --- php-src/ext/mysqli/tests/connect.inc:1.1 Thu Feb 13 13:21:37 2003 +++ php-src/ext/mysqli/tests/connect.inc Fri Jan 7 09:59:59 2005 @@ -3,8 +3,24 @@ /* default values are localhost, root and empty password Change the values if you use another configuration */ - $host = "localhost"; - $user = "root"; - $passwd = ""; + $driver = new mysqli_driver; + + if (!$driver->embedded) { + $host = "localhost"; + $user = "root"; + $passwd = ""; + + $driver->embedded_server_start(FALSE, NULL, NULL); + } else { + $path = realpath('./ext/mysqli/tests'); + $host = $user = $passwd = NULL; + $args = array( + "--datadir=$path", + "--innodb_data_home_dir=$path", + "--innodb_data_file_path=ibdata1:10M:autoextend", + "--log-error=$path/testrun.log" + ); + $driver->embedded_server_start(TRUE, $args, NULL); + } ?> http://cvs.php.net/diff.php/php-src/ext/mysqli/tests/skipif.inc?r1=1.1&r2=1.2&ty=u Index: php-src/ext/mysqli/tests/skipif.inc diff -u php-src/ext/mysqli/tests/skipif.inc:1.1 php-src/ext/mysqli/tests/skipif.inc:1.2 --- php-src/ext/mysqli/tests/skipif.inc:1.1 Sat Dec 4 03:50:33 2004 +++ php-src/ext/mysqli/tests/skipif.inc Fri Jan 7 09:59:59 2005 @@ -1 +1,4 @@ -<?php if (!extension_loaded('mysqli')) die('skip mysqli extension not available');?> +<?php + if (!extension_loaded('mysqli')) + die('skip mysqli extension not available'); +?> http://cvs.php.net/co.php/php-src/ext/mysqli/mysqli_driver.c?r=1.1&p=1 Index: php-src/ext/mysqli/mysqli_driver.c +++ php-src/ext/mysqli/mysqli_driver.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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_0.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 | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ #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) \ 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) \ 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) \ 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) \ 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) \ 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) \ int name(mysqli_object *obj, zval *value TSRMLS_DC) \ { \ MyG(value) = Z_STRVAL_P(value); \ return SUCCESS; \ } \ /* {{{ property driver_report_write */ 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_CC); return SUCCESS; } /* }}} */ /* {{{ property driver_embedded_read */ 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 */ 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 */ 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 */ 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[] */ 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} }; /* }}} */ http://cvs.php.net/co.php/php-src/ext/mysqli/mysqli_embedded.c?r=1.1&p=1 Index: php-src/ext/mysqli/mysqli_embedded.c +++ php-src/ext/mysqli/mysqli_embedded.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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_0.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 | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ #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) { 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; } if (MyG(embedded)) { /* 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); 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); 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, NULL); if (argc) { efree(arguments); } efree(groups); if (rc) { RETURN_FALSE; } RETURN_TRUE; } php_error_docref(NULL TSRMLS_CC, E_ERROR, "Can't start embedded server. PHP wasn't configured with mysql embedded server support"); } /* }}} */ /* {{{ proto void mysqli_embedded_server_end(void) */ PHP_FUNCTION(mysqli_embedded_server_end) { mysql_server_end(); } /* }}} */ http://cvs.php.net/co.php/php-src/ext/mysqli/mysqli_exception.c?r=1.1&p=1 Index: php-src/ext/mysqli/mysqli_exception.c +++ php-src/ext/mysqli/mysqli_exception.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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_0.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 | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ #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[] */ 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); zend_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); 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); } http://cvs.php.net/co.php/php-src/ext/mysqli/mysqli_warning.c?r=1.1&p=1 Index: php-src/ext/mysqli/mysqli_warning.c +++ php-src/ext/mysqli/mysqli_warning.c /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 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_0.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 | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Georg Richter <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ #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) { if (w->result) { mysql_free_result(w->result); } efree(w); } /* }}} */ /* {{{ void php_get_warnings(MYSQL *mysql) */ MYSQLI_WARNING *php_get_warnings(MYSQL *mysql) { MYSQLI_WARNING *w; int cwarnings; if (!(cwarnings = mysql_warning_count(mysql))) { return NULL; } if (mysql_query(mysql, "SHOW WARNINGS")) { return NULL; } if (!(w = (MYSQLI_WARNING *)ecalloc(sizeof(MYSQLI_WARNING), 1))) { return NULL; } w->warning_count = cwarnings; w->result = mysql_store_result(mysql); if (!(w->row = mysql_fetch_row(w->result))) { mysql_free_result(w->result); efree(w); return NULL; } return w; } /* }}} */ /* {{{ mysqli_warning::__construct */ ZEND_FUNCTION(mysqli_warning_construct) { MYSQL *mysql = NULL; MYSQLI_WARNING *w; MYSQLI_RESOURCE *mysqli_resource; mysqli_object *obj; if (!getThis()) { RETURN_FALSE; } obj = (mysqli_object *)zend_objects_get_address(getThis() TSRMLS_CC); if (obj->zo.ce == mysqli_link_class_entry) { mysql = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql; } else if (obj->zo.ce == mysqli_stmt_class_entry) { mysql = (MYSQL *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt->mysql; } if ((w = php_get_warnings(mysql))) { mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource->ptr = (void *)w; obj->valid = 1; MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry); } else { RETURN_FALSE; } } /* }}} */ /* {{{ bool mysqli_warning::next */ ZEND_FUNCTION(mysqli_warning_next) { MYSQLI_WARNING *w; zval *mysql_warning; mysqli_object *obj = (mysqli_object *)zend_objects_get_address(getThis() TSRMLS_CC); if (obj->valid) { if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_warning, mysqli_warning_class_entry) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysql_warning, "mysqli_warning"); if (w->warning_count && (w->row = mysql_fetch_row(w->result))) { RETURN_TRUE; } } RETURN_FALSE; } /* }}} */ /* {{{ property mysqli_warning_error */ int mysqli_warning_error(mysqli_object *obj, zval **retval TSRMLS_DC) { MYSQLI_WARNING *w; ALLOC_ZVAL(*retval); w = obj->valid ? (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr : NULL; if (w && w->row && w->row[2]) { ZVAL_STRING(*retval, w->row[2], 1); } else { ZVAL_NULL(*retval); } return SUCCESS; } /* }}} */ /* {{{ property mysqli_warning_error */ int mysqli_warning_errno(mysqli_object *obj, zval **retval TSRMLS_DC) { MYSQLI_WARNING *w; ALLOC_ZVAL(*retval); w = obj->valid ? (MYSQLI_WARNING *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr : NULL; if (w && w->row && w->row[1]) { ZVAL_LONG(*retval, atoi(w->row[1])); } else { ZVAL_NULL(*retval); } return SUCCESS; } /* }}} */ /* {{{ mysqli_warning_methods[] */ function_entry mysqli_warning_methods[] = { PHP_FALIAS(__construct,mysqli_warning_construct, NULL) PHP_FALIAS(next,mysqli_warning_next,NULL) {NULL, NULL, NULL} }; /* }}} */ mysqli_property_entry mysqli_warning_property_entries[] = { {"error", mysqli_warning_error, NULL}, {"errno", mysqli_warning_errno, NULL}, {NULL, NULL, NULL} }; http://cvs.php.net/co.php/php-src/ext/mysqli/tests/skipifemb.inc?r=1.1&p=1 Index: php-src/ext/mysqli/tests/skipifemb.inc +++ php-src/ext/mysqli/tests/skipifemb.inc <?php $driver = new mysqli_driver(); if ($driver->embedded) die("skip test doesn't run with embedded server"); ?>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php