Merge from 5.2

This commit is contained in:
Georg Richter 2006-05-09 11:27:20 +00:00
parent 1a0f27a707
commit b6d7fdf465
13 changed files with 426 additions and 348 deletions

View File

@ -43,6 +43,13 @@ 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);
@ -144,25 +151,23 @@ static void mysqli_objects_destroy_object(void *object, zend_object_handle handl
if (instanceof_function(intern->zo.ce, mysqli_link_class_entry TSRMLS_CC)) {
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);
my_res->ptr = NULL;
}
} else if (intern->zo.ce == mysqli_stmt_class_entry) { /* stmt object */
} else if (instanceof_function(intern->zo.ce, mysqli_stmt_class_entry TSRMLS_CC)) { /* stmt obj */
if (my_res && my_res->ptr) {
php_clear_stmt_bind((MY_STMT *)my_res->ptr);
MY_STMT *stmt = (MY_STMT *)my_res->ptr;
php_clear_stmt_bind(stmt);
}
} else if (intern->zo.ce == mysqli_result_class_entry) { /* result object */
} else if (instanceof_function(intern->zo.ce, mysqli_result_class_entry TSRMLS_CC)) { /* result obj */
if (my_res && my_res->ptr) {
mysql_free_result(my_res->ptr);
}
} else if (intern->zo.ce == mysqli_warning_class_entry) { /* warning object */
} else if (instanceof_function(intern->zo.ce, mysqli_warning_class_entry TSRMLS_CC)) { /* warning obj */
if (my_res && my_res->ptr) {
php_clear_warnings((MYSQLI_WARNING *)my_res->info);
}
@ -214,22 +219,11 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)
}
if (ret == SUCCESS) {
/* check if mysqli object is still valid */
if (!strcmp(obj->zo.ce->name.s, "mysqli")) {
if (!obj->ptr ||
!((MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql)->thread_id) {
retval = EG(uninitialized_zval_ptr);
return(retval);
}
} else
/* check if stmt object is still valid */
if (!strcmp(obj->zo.ce->name.s, "mysqli_stmt")) {
if (!obj->ptr ||
!((MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt)->mysql) {
retval = EG(uninitialized_zval_ptr);
return(retval);
}
if (strcmp(obj->zo.ce->name.s, "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);
@ -328,7 +322,7 @@ static union _zend_function *php_mysqli_constructor_get(zval *object TSRMLS_DC)
} 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);
f.handler = ZEND_FN(mysqli_warning_construct);
}
return (union _zend_function*)&f;
@ -347,7 +341,6 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
intern = emalloc(sizeof(mysqli_object));
memset(intern, 0, sizeof(mysqli_object));
intern->ptr = NULL;
intern->valid = 0;
intern->prop_handler = NULL;
mysqli_base_class = class_type;
@ -355,6 +348,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
{
mysqli_base_class = mysqli_base_class->parent;
}
zend_hash_find(&classes, mysqli_base_class->name.s, mysqli_base_class->name_length + 1,
(void **) &intern->prop_handler);
@ -566,6 +560,10 @@ PHP_MINIT_FUNCTION(mysqli)
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);
@ -633,10 +631,10 @@ 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 version", mysql_get_client_info());
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();
@ -646,7 +644,7 @@ PHP_MINFO_FUNCTION(mysqli)
/* {{{ mixed mysqli_stmt_construct()
constructor for statement object.
Parameters:
object -> mysqli_init
object -> mysqli_stmt_init
object, query -> mysqli_prepare
*/
ZEND_FUNCTION(mysqli_stmt_construct)
@ -664,17 +662,17 @@ ZEND_FUNCTION(mysqli_stmt_construct)
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_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) {
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_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
@ -694,9 +692,9 @@ ZEND_FUNCTION(mysqli_stmt_construct)
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;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
/* }}} */
@ -728,7 +726,7 @@ ZEND_FUNCTION(mysqli_result_construct)
WRONG_PARAM_COUNT;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link");
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);
@ -739,10 +737,9 @@ ZEND_FUNCTION(mysqli_result_construct)
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;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
/* }}} */
@ -790,7 +787,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
}
}
}
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result");
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");
@ -976,6 +973,7 @@ int php_local_infile_init(void **ptr, const char *filename, void *userdata)
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;
}

File diff suppressed because it is too large Load Diff

View File

@ -238,6 +238,7 @@ zend_function_entry mysqli_link_methods[] = {
* Every user visible function must have an entry in mysqli_result_functions[].
*/
zend_function_entry mysqli_result_methods[] = {
PHP_FALIAS(__construct, 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)
@ -260,6 +261,7 @@ zend_function_entry mysqli_result_methods[] = {
* Every user visible function must have an entry in mysqli_stmt_functions[].
*/
zend_function_entry mysqli_stmt_methods[] = {
PHP_FALIAS(__construct,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)

View File

@ -111,12 +111,12 @@ PHP_FUNCTION(mysqli_connect)
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;
((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->valid = 1;
}
}
/* }}} */
@ -177,7 +177,7 @@ PHP_FUNCTION(mysqli_multi_query)
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_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_ENABLE_MQ;
if (mysql_real_query(mysql->mysql, query, query_len)) {
@ -228,7 +228,7 @@ PHP_FUNCTION(mysqli_query)
RETURN_FALSE;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link");
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
MYSQLI_DISABLE_MQ;
@ -259,6 +259,7 @@ PHP_FUNCTION(mysqli_query)
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);
}
/* }}} */
@ -274,7 +275,7 @@ PHP_FUNCTION(mysqli_get_warnings)
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_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (mysql_warning_count(mysql->mysql)) {
w = php_get_warnings(mysql->mysql);
@ -298,7 +299,7 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
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");
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT*, &stmt_link, "mysqli_stmt", MYSQLI_STATUS_VALID);
if (mysql_warning_count(stmt->stmt->mysql)) {
w = php_get_warnings(stmt->stmt->mysql);
@ -324,9 +325,9 @@ PHP_FUNCTION(mysqli_set_charset)
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_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (!mysql->mysql->thread_id || mysql_set_character_set(mysql->mysql, cs_name)) {
if (mysql_set_character_set(mysql->mysql, cs_name)) {
RETURN_FALSE;
}
RETURN_TRUE;
@ -346,7 +347,7 @@ PHP_FUNCTION(mysqli_get_charset)
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_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
object_init(return_value);

View File

@ -29,51 +29,49 @@
#include "ext/standard/info.h"
#include "php_mysqli.h"
#define CHECK_OBJECT() \
if (!obj->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Property access is not allowed yet. Call the default constructor of the object first"); \
#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() \
#define MYSQLI_GET_MYSQL(statusval) \
MYSQL *p; \
ALLOC_ZVAL(*retval);\
CHECK_OBJECT();\
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 if (!obj->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid resource %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
return SUCCESS; \
} else { \
p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql; \
CHECK_STATUS(statusval);\
p = (MYSQL *)((MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->mysql;\
}
#define MYSQLI_GET_RESULT() \
#define MYSQLI_GET_RESULT(statusval) \
MYSQL_RES *p; \
ALLOC_ZVAL(*retval);\
CHECK_OBJECT();\
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 if (!obj->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid resource %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() \
#define MYSQLI_GET_STMT(statusval) \
MYSQL_STMT *p; \
ALLOC_ZVAL(*retval);\
CHECK_OBJECT();\
p = (MYSQL_STMT *)((MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr)->stmt
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) \
@ -88,7 +86,7 @@ static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \
ZVAL_LONG(*retval, l);\
} else { \
char ret[40]; \
sprintf(ret, "%llu", (my_ulonglong)l); \
sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong)l); \
ZVAL_STRING(*retval, ret, 1); \
} \
}\
@ -126,6 +124,7 @@ static int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
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;
}
@ -135,6 +134,7 @@ static int link_client_info_read(mysqli_object *obj, zval **retval TSRMLS_DC)
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;
}
@ -144,6 +144,7 @@ static int link_connect_errno_read(mysqli_object *obj, zval **retval TSRMLS_DC)
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;
}
@ -156,41 +157,46 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
my_ulonglong rc;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
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);
if (!mysql) {
ZVAL_NULL(*retval);
} else {
char ret[40];
sprintf(ret, "%llu", (my_ulonglong) rc);
ZVAL_STRING(*retval, ret, 1);
}
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(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_error_read, mysql_error, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_field_count_read, mysql_field_count, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_host_info_read, mysql_get_host_info, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_info_read, mysql_info, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_insert_id_read, mysql_insert_id, MYSQLI_GET_MYSQL(), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_protocol_version_read, mysql_get_proto_info, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_server_info_read, mysql_get_server_info, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_server_version_read, mysql_get_server_version, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_MYSQL());
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(), ulong);
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 */
@ -199,7 +205,7 @@ static int result_type_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MYSQL_RES *p;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (!p) {
@ -217,15 +223,15 @@ static int result_lengths_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MYSQL_RES *p;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
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++) {
@ -239,9 +245,9 @@ static int result_lengths_read(mysqli_object *obj, zval **retval TSRMLS_DC)
/* }}} */
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_current_field_read, mysql_field_tell, MYSQLI_GET_RESULT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_field_count_read, mysql_num_fields, MYSQLI_GET_RESULT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(result_num_rows_read, mysql_num_rows, MYSQLI_GET_RESULT(), my_ulonglong);
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 */
@ -251,7 +257,7 @@ static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC)
MY_STMT *p;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
@ -267,39 +273,43 @@ static int stmt_id_read(mysqli_object *obj, zval **retval TSRMLS_DC)
/* {{{ property stmt_affected_rows_read */
static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
MY_STMT *stmt;
MY_STMT *p;
my_ulonglong rc;
ALLOC_ZVAL(*retval);
CHECK_OBJECT();
CHECK_STATUS(MYSQLI_STATUS_VALID);
stmt = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
rc = mysql_stmt_affected_rows(stmt->stmt);
p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (rc == (my_ulonglong)-1) {
ZVAL_LONG(*retval, -1);
return SUCCESS;
}
if (rc < LONG_MAX) {
ZVAL_LONG(*retval, rc);
if (!p) {
ZVAL_NULL(*retval);
} else {
char ret[40];
sprintf(ret, "%llu", (my_ulonglong) rc);
ZVAL_STRING(*retval, ret, 1);
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(), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_num_rows_read, mysql_stmt_num_rows, MYSQLI_GET_STMT(), my_ulonglong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_param_count_read, mysql_stmt_param_count, MYSQLI_GET_STMT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_field_count_read, mysql_stmt_field_count, MYSQLI_GET_STMT(), ulong);
MYSQLI_MAP_PROPERTY_FUNC_LONG(stmt_errno_read, mysql_stmt_errno, MYSQLI_GET_STMT(), ulong);
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_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[] = {

View File

@ -39,7 +39,7 @@ PHP_FUNCTION(mysqli_disable_reads_from_master)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
mysql_disable_reads_from_master(mysql);
RETURN_TRUE;
}
@ -55,7 +55,7 @@ PHP_FUNCTION(mysqli_disable_rpl_parse)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
mysql_disable_rpl_parse(mysql);
RETURN_TRUE;
}
@ -71,7 +71,7 @@ PHP_FUNCTION(mysqli_enable_reads_from_master)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
mysql_enable_reads_from_master(mysql);
RETURN_TRUE;
@ -88,7 +88,7 @@ PHP_FUNCTION(mysqli_enable_rpl_parse)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
mysql_enable_rpl_parse(mysql);
RETURN_TRUE;
@ -106,7 +106,7 @@ PHP_FUNCTION(mysqli_master_query) {
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (mysql_master_query(mysql, query, query_len)) {
RETURN_FALSE;
@ -125,7 +125,7 @@ PHP_FUNCTION(mysqli_rpl_parse_enabled)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
RETURN_LONG(mysql_rpl_parse_enabled(mysql));
}
@ -141,7 +141,7 @@ PHP_FUNCTION(mysqli_rpl_probe)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (mysql_rpl_probe(mysql)) {
@ -163,7 +163,7 @@ PHP_FUNCTION(mysqli_rpl_query_type)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
RETURN_LONG(mysql_rpl_query_type(query, query_len));
}
@ -181,7 +181,7 @@ PHP_FUNCTION(mysqli_send_query)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (mysql_send_query(mysql, query, query_len)) {
RETURN_FALSE;
@ -202,7 +202,7 @@ PHP_FUNCTION(mysqli_slave_query)
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_FETCH_RESOURCE(mysql, MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
if (mysql_slave_query(mysql, query, query_len)) {
RETURN_FALSE;

View File

@ -100,7 +100,7 @@ PHP_METHOD(mysqli_warning, next)
return;
}
MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysqli_warning, "mysqli_warning");
MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, &mysqli_warning, "mysqli_warning", MYSQLI_STATUS_VALID);
if (w->next) {
w = w->next;
@ -164,7 +164,7 @@ int mysqli_warning_errno(mysqli_object *obj, zval **retval TSRMLS_DC)
/* }}} */
/* {{{ mysqli_warning_construct(object obj) */
PHP_METHOD(mysqli_warning, __construct)
PHP_FUNCTION(mysqli_warning_construct)
{
zval *z;
mysqli_object *obj;
@ -182,11 +182,11 @@ PHP_METHOD(mysqli_warning, __construct)
if (obj->zo.ce == mysqli_link_class_entry) {
MY_MYSQL *mysql;
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &z, "mysqli_link");
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_FETCH_RESOURCE(stmt, MY_STMT *, &z, "mysqli_stmt", MYSQLI_STATUS_VALID);
hdl = stmt->stmt->mysql;
} else {
RETURN_FALSE;
@ -200,20 +200,20 @@ PHP_METHOD(mysqli_warning, __construct)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = mysqli_resource->info = (void *)w;
mysqli_resource->status = MYSQLI_STATUS_VALID;
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;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
}
/* }}} */
zend_function_entry mysqli_warning_methods[] = {
PHP_ME(mysqli_warning, __construct, NULL, ZEND_ACC_PROTECTED)
PHP_ME(mysqli_warning, next, NULL, ZEND_ACC_PUBLIC)
PHP_FALIAS(mysqli_warning, mysqli_warning_construct, NULL)
ZEND_ME(mysqli_warning, next, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};

View File

@ -43,6 +43,13 @@
#define MYSQLI_VERSION_ID 101008
enum mysqli_status {
MYSQLI_STATUS_UNKNOWN=0,
MYSQLI_STATUS_CLEARED,
MYSQLI_STATUS_INITIALIZED,
MYSQLI_STATUS_VALID
};
typedef struct {
ulong buflen;
char *val;
@ -64,10 +71,10 @@ typedef struct {
} MY_STMT;
typedef struct {
MYSQL *mysql;
zval *li_read;
php_stream *li_stream;
unsigned int multi_query;
MYSQL *mysql;
zval *li_read;
php_stream *li_stream;
unsigned int multi_query;
} MY_MYSQL;
typedef struct {
@ -77,14 +84,14 @@ typedef struct {
} PROFILER;
typedef struct {
void *ptr; /* resource: (mysql, result, stmt) */
void *info; /* additional buffer */
void *ptr; /* resource: (mysql, result, stmt) */
void *info; /* additional buffer */
enum mysqli_status status; /* object status */
} MYSQLI_RESOURCE;
typedef struct _mysqli_object {
zend_object zo;
void *ptr;
char valid;
HashTable *prop_handler;
} mysqli_object; /* extends zend_object */
@ -110,8 +117,16 @@ typedef struct {
#ifdef PHP_WIN32
#define PHP_MYSQLI_API __declspec(dllexport)
#define MYSQLI_LLU_SPEC "%I64u"
#define MYSQLI_LL_SPEC "%I64d"
#define L64(x) x##i64
typedef __int64 my_longlong;
#else
#define PHP_MYSQLI_API
#define MYSQLI_LLU_SPEC "%llu"
#define MYSQLI_LL_SPEC "%lld"
#define L64(x) x##LL
typedef long long my_longlong;
#endif
#ifdef ZTS
@ -149,12 +164,12 @@ 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;
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;
@ -179,14 +194,13 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
mysqli_entry = zend_register_internal_class(&ce TSRMLS_CC); \
} \
#define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval, __ce) \
((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->ptr = __ptr; \
((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->valid = 1;
#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, __ce)
MYSQLI_REGISTER_RESOURCE_EX(__ptr, return_value)
#define MYSQLI_REGISTER_RESOURCE(__ptr, __ce) \
{\
@ -196,10 +210,10 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
Z_TYPE_P(object) = IS_OBJECT;\
(object)->value.obj = mysqli_objects_new(__ce TSRMLS_CC);\
}\
MYSQLI_REGISTER_RESOURCE_EX(__ptr, object, __ce)\
MYSQLI_REGISTER_RESOURCE_EX(__ptr, object)\
}
#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name) \
#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);\
@ -207,18 +221,18 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);\
RETURN_NULL();\
}\
if (!intern->valid) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid resource %s", intern->zo.ce->name); \
RETURN_NULL(); \
} \
__ptr = (__type)my_res->ptr; \
if (!strcmp((char *)__name, "mysqli_stmt")) {\
if (!((MY_STMT *)__ptr)->stmt->mysql) {\
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Statement isn't valid anymore");\
RETURN_NULL();\
}\
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) \
{ \
@ -411,7 +425,7 @@ PHP_FUNCTION(mysqli_warning_count);
ZEND_FUNCTION(mysqli_stmt_construct);
ZEND_FUNCTION(mysqli_result_construct);
ZEND_FUNCTION(mysqli_driver_construct);
PHP_METHOD(mysqli_warning, __construct);
ZEND_FUNCTION(mysqli_warning_construct);
ZEND_BEGIN_MODULE_GLOBALS(mysqli)
long default_link;

View File

@ -8,6 +8,7 @@ mysqli bind_result 1
/*** 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");

View File

@ -9,9 +9,9 @@ mysqli autocommit/commit/rollback
$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--

View File

@ -12,15 +12,13 @@ mysqli fetch functions
mysqli_select_db($link, "test");
$stmt = mysqli_prepare($link, "SELECT current_user(), database(), 'foo'");
$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);
$c0 = ($c0 == $user . "@" . $host) ? 1 : 0;
$test = array($c0, $c1, $c2);
var_dump($test);
@ -29,7 +27,7 @@ mysqli fetch functions
--EXPECT--
array(3) {
[0]=>
int(1)
string(32) "37b51d194a7513e45b56f6524f2d51f2"
[1]=>
string(4) "test"
[2]=>

View File

@ -11,14 +11,16 @@ mysql_fetch_row (OO-Style)
$mysql = mysqli_connect($host, $user, $passwd);
$mysql->select_db("test");
$result = $mysql->query("SELECT CURRENT_USER()");
$result = $mysql->query("SELECT DATABASE()");
$row = $result->fetch_row();
$result->close();
$ok = ($row[0] == $user . "@" . $host);
var_dump($ok);
var_dump($row);
$mysql->close();
?>
--EXPECT--
bool(true)
array(1) {
[0]=>
string(4) "test"
}

View File

@ -9,15 +9,16 @@ class DbConnection {
public function connect() {
include "connect.inc";
$link = mysqli::connect($host, $user, $passwd);
$link = mysqli_connect($host, $user, $passwd);
var_dump($link);
$link = mysqli::init();
$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));
}