- Fixed PECL bug #12431 (OCI8 ping functionality is broken). (Oracle Corp.)
- Fixed bug #44414 (Incomplete reporting about abstract methods). (Dmitry)
+- Fixed bug #44352 (mysqli_connect_error() false negative for host errors).
+ (Andrey)
- Fixed bug #44336 (Improve pcre UTF-8 string matching performance).
(frode at coretrek dot com, Nuno)
- Fixed bug #44257 (timelib_tz_lookup_table must use float for gmtoffset).
| 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> |
+ | Authors: Georg Richter <georg@php.net> |
+ | Andrey Hristov <andrey@php.net> |
+ | Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
$Id$
ZEND_DECLARE_MODULE_GLOBALS(mysqli)
static PHP_GINIT_FUNCTION(mysqli);
+#define MYSQLI_ADD_PROPERTIES(a,b) \
+{ \
+ int i = 0; \
+ while (b[i].pname != NULL) { \
+ mysqli_add_property((a), (b)[i].pname, (b)[i].pname_length, \
+ (mysqli_read_t)(b)[i].r_func, (mysqli_write_t)(b)[i].w_func TSRMLS_CC); \
+ i++; \
+ }\
+}
+
+#define MYSQLI_ADD_PROPERTIES_INFO(a,b) \
+{ \
+ int i = 0; \
+ while (b[i].name != NULL) { \
+ zend_declare_property_null((a), (b)[i].name, (b)[i].name_length, ZEND_ACC_PUBLIC TSRMLS_CC); \
+ i++; \
+ }\
+}
+
+
+
static zend_object_handlers mysqli_object_handlers;
static HashTable classes;
static HashTable mysqli_driver_properties;
MYSQLND_QCACHE *mysqli_mysqlnd_qcache;
#endif
+
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 {
+ char *name;
+ size_t name_len;
mysqli_read_t read_func;
mysqli_write_t write_func;
} mysqli_prop_handler;
mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT);
}
-/* le_pmysqli dtor*/
+
ZEND_RSRC_DTOR_FUNC(php_mysqli_dtor)
{
if (rsrc->ptr) {
/* }}} */
/* {{{ 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) {
+void mysqli_add_property(HashTable *h, const char *pname, size_t pname_len, mysqli_read_t r_func, mysqli_write_t w_func TSRMLS_DC) {
mysqli_prop_handler p;
+ p.name = (char*) pname;
+ p.name_len = pname_len;
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);
+ zend_hash_add(h, pname, pname_len + 1, &p, sizeof(mysqli_prop_handler), NULL);
}
/* }}} */
}
}
+static int mysqli_object_has_property(zval *object, zval *member, int has_set_exists TSRMLS_DC) /* {{{ */
+{
+ mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC);
+ mysqli_prop_handler p;
+ int ret = 0;
+
+ if (zend_hash_find(obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member) + 1, (void **)&p) == SUCCESS) {
+ switch (has_set_exists) {
+ case 2:
+ ret = 1;
+ break;
+ case 1: {
+ zval *value = mysqli_read_property(object, member, BP_VAR_IS TSRMLS_CC);
+ if (value != EG(uninitialized_zval_ptr)) {
+ convert_to_boolean(value);
+ ret = Z_BVAL_P(value)? 1:0;
+ /* refcount is 0 */
+ Z_ADDREF_P(value);
+ zval_ptr_dtor(&value);
+ }
+ break;
+ }
+ case 0:{
+ zval *value = mysqli_read_property(object, member, BP_VAR_IS TSRMLS_CC);
+ if (value != EG(uninitialized_zval_ptr)) {
+ ret = Z_TYPE_P(value) != IS_NULL? 1:0;
+ /* refcount is 0 */
+ Z_ADDREF_P(value);
+ zval_ptr_dtor(&value);
+ }
+ break;
+ }
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid value for has_set_exists");
+ }
+ }
+ return ret;
+} /* }}} */
+
+
+HashTable * mysqli_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
+{
+ mysqli_object *obj = (mysqli_object *)zend_objects_get_address(object TSRMLS_CC);
+ HashTable *retval, *props = obj->prop_handler;
+ HashPosition pos;
+ mysqli_prop_handler *entry;
+
+ ALLOC_HASHTABLE(retval);
+ ZEND_INIT_SYMTABLE_EX(retval, zend_hash_num_elements(props) + 1, 0);
+
+ zend_hash_internal_pointer_reset_ex(props, &pos);
+ while (zend_hash_get_current_data_ex(props, (void **)&entry, &pos) == SUCCESS) {
+ zval member;
+ zval *value;
+ INIT_ZVAL(member);
+ ZVAL_STRINGL(&member, entry->name, entry->name_len, 0);
+ value = mysqli_read_property(object, &member, BP_VAR_IS TSRMLS_CC);
+ if (value != EG(uninitialized_zval_ptr)) {
+ Z_ADDREF_P(value);
+ zend_hash_add(retval, entry->name, entry->name_len + 1, &value, sizeof(zval *), NULL);
+ }
+ zend_hash_move_forward_ex(props, &pos);
+ }
+
+ *is_temp = 1;
+ return retval;
+}
+
+
/* {{{ mysqli_objects_new
*/
PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_type TSRMLS_DC)
intern->prop_handler = NULL;
mysqli_base_class = class_type;
- while (mysqli_base_class->type != ZEND_INTERNAL_CLASS && mysqli_base_class->parent != NULL) {
+ 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,
/* Dependancies */
-const static zend_module_dep mysqli_deps[] = {
+static const zend_module_dep mysqli_deps[] = {
#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
ZEND_MOD_REQUIRED("spl")
#endif
mysqli_globals->num_active_persistent = 0;
mysqli_globals->num_inactive_persistent = 0;
mysqli_globals->max_links = -1;
- mysqli_globals->max_links = -1;
mysqli_globals->max_persistent = -1;
mysqli_globals->allow_persistent = 1;
mysqli_globals->default_port = 0;
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;
+ mysqli_object_handlers.has_property = mysqli_object_has_property;
+ mysqli_object_handlers.get_debug_info = mysqli_object_get_debug_info;
zend_hash_init(&classes, 0, NULL, NULL, 1);
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);
+ MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_driver_property_info_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;
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);
+ MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_link_property_info_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->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);
+ MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_warning_property_info_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);
+ MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_result_property_info_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);
+ MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_stmt_property_info_entries);
zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_stmt_properties, sizeof(mysqli_stmt_properties), NULL);
/* mysqli_options */
*/
PHP_MINFO_FUNCTION(mysqli)
{
+#if defined(MYSQLI_USE_MYSQLND)
char buf[32];
+#endif
php_info_print_table_start();
php_info_print_table_header(2, "MysqlI Support", "enabled");
object -> mysqli_stmt_init
object, query -> mysqli_prepare
*/
-ZEND_FUNCTION(mysqli_stmt_construct)
+PHP_FUNCTION(mysqli_stmt_construct)
{
MY_MYSQL *mysql;
zval *mysql_link;
stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
- mysql_stmt_prepare(stmt->stmt, statement, statement_len);
+ mysql_stmt_prepare(stmt->stmt, (char *)statement, statement_len);
}
break;
default:
Parameters:
object [, mode] -> mysqli_store/use_result
*/
-ZEND_FUNCTION(mysqli_result_construct)
+PHP_FUNCTION(mysqli_result_construct)
{
MY_MYSQL *mysql;
MYSQL_RES *result = NULL;
}
/* }}} */
-/* {{{ 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);
-}
-/* }}} */
#if !defined(MYSQLI_USE_MYSQLND)
}
#define LOCAL_INFILE_ERROR_MSG(source,dest)\
-memset(source, 0, LOCAL_INFILE_ERROR_LEN);\
-memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));
+ memset(source, 0, LOCAL_INFILE_ERROR_LEN);\
+ memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));\
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, dest);
-/* {{{ 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);
- if (mysql->li_read) {
- zval_ptr_dtor(&mysql->li_read);
- mysql->li_read = NULL;
- }
-}
-/* }}} */
/* {{{ php_local_infile_init
*/
-int php_local_infile_init(void **ptr, const char *filename, void *userdata)
+static int php_local_infile_init(void **ptr, const char *filename, void *userdata)
{
mysqli_local_infile *data;
- MY_MYSQL *mysql;
+ MY_MYSQL *mysql;
php_stream_context *context = NULL;
TSRMLS_FETCH();
/* }}} */
/* {{{ int php_local_infile_read */
-int php_local_infile_read(void *ptr, char *buf, uint buf_len)
+static int php_local_infile_read(void *ptr, char *buf, uint buf_len)
{
- mysqli_local_infile *data;
+ mysqli_local_infile *data;
MY_MYSQL *mysql;
zval ***callback_args;
zval *retval;
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,
/* {{{ php_local_infile_error
*/
-int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
+static int php_local_infile_error(void *ptr, char *error_msg, uint error_msg_len)
{
mysqli_local_infile *data = (mysqli_local_infile *) ptr;
/* {{{ php_local_infile_end
*/
-void php_local_infile_end(void *ptr)
+static void php_local_infile_end(void *ptr)
{
mysqli_local_infile *data;
MY_MYSQL *mysql;
return;
}
/* }}} */
+
+
+/* {{{ 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);
+ if (mysql->li_read) {
+ zval_ptr_dtor(&mysql->li_read);
+ mysql->li_read = NULL;
+ }
+}
+/* }}} */
#endif
/*
#define MAP_PROPERTY_MYG_BOOL_READ(name, value) \
static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
{ \
- ALLOC_ZVAL(*retval); \
+ MAKE_STD_ZVAL(*retval); \
ZVAL_BOOL(*retval, MyG(value)); \
return SUCCESS; \
} \
#define MAP_PROPERTY_MYG_LONG_READ(name, value) \
static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
{ \
- ALLOC_ZVAL(*retval); \
+ MAKE_STD_ZVAL(*retval); \
ZVAL_LONG(*retval, MyG(value)); \
return SUCCESS; \
} \
#define MAP_PROPERTY_MYG_STRING_READ(name, value) \
static int name(mysqli_object *obj, zval **retval TSRMLS_DC) \
{ \
- ALLOC_ZVAL(*retval); \
+ MAKE_STD_ZVAL(*retval); \
ZVAL_STRING(*retval, MyG(value), 1); \
return SUCCESS; \
} \
/* {{{ property driver_embedded_read */
static int driver_embedded_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
#ifdef HAVE_EMBEDDED_MYSQLI
ZVAL_BOOL(*retval, 1);
#else
/* {{{ property driver_client_version_read */
static int driver_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
- ALLOC_ZVAL(*retval);
+ MAKE_STD_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);
+ MAKE_STD_ZVAL(*retval);
ZVAL_STRING(*retval, (char *)mysql_get_client_info(), 1);
return SUCCESS;
}
/* {{{ property driver_driver_version_read */
static int driver_driver_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
ZVAL_LONG(*retval, MYSQLI_VERSION_ID);
return SUCCESS;
}
}
const 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}
+ {"client_info", sizeof("client_info") - 1, driver_client_info_read, NULL},
+ {"client_version", sizeof("client_version") - 1, driver_client_version_read, NULL},
+ {"driver_version", sizeof("driver_version") - 1, driver_driver_version_read, NULL},
+ {"embedded", sizeof("embedded") - 1, driver_embedded_read, NULL},
+ {"reconnect", sizeof("reconnect") - 1, driver_reconnect_read, driver_reconnect_write},
+ {"report_mode", sizeof("report_mode") - 1, driver_report_read, driver_report_write},
+ {NULL, 0, NULL, NULL}
+};
+
+/* {{{ mysqli_warning_property_info_entries */
+zend_property_info mysqli_driver_property_info_entries[] = {
+ {ZEND_ACC_PUBLIC, "client_info", sizeof("client_info") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "client_version", sizeof("client_version") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "driver_version", sizeof("driver_version") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "embedded", sizeof("embedded") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "reconnect", sizeof("reconnect") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "report_mode", sizeof("report_mode") - 1, 0, NULL, 0, NULL},
+ {0, NULL, 0, 0, NULL, 0, NULL},
};
+/* }}} */
+
/* {{{ mysqli_driver_methods[]
*/
#define SAFE_STR(a) ((a)?a:"")
+/* {{{ php_mysqli_set_error
+ */
+static 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);
+}
+/* }}} */
+
+
void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect, zend_bool in_ctor)
{
MY_MYSQL *mysql = NULL;
port, socket, flags, MyG(mysqlnd_thd_zval_cache) TSRMLS_CC) == NULL)
#endif
{
- /* Save error messages */
+ /* Save error messages - for mysqli_connect_error() & mysqli_connect_errno() */
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC);
php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
"%s", mysql_error(mysql->mysql));
break;
#endif
}
-
if (!result) {
php_mysqli_throw_sql_exception((char *)mysql_sqlstate(mysql->mysql), mysql_errno(mysql->mysql) TSRMLS_CC,
"%s", mysql_error(mysql->mysql));
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = mysqli_resource->info = (void *)w;
mysqli_resource->status = MYSQLI_STATUS_VALID;
- MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
+ MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_warning_class_entry);
}
/* }}} */
{
MY_MYSQL *mysql;
zval *mysql_link;
- char *cs_name = NULL;
- unsigned int len;
+ char *cs_name;
+ int csname_len;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &mysql_link, mysqli_link_class_entry, &cs_name, &csname_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL*, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
#define MYSQLI_GET_MYSQL(statusval) \
MYSQL *p; \
-ALLOC_ZVAL(*retval);\
+MAKE_STD_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);\
#define MYSQLI_GET_RESULT(statusval) \
MYSQL_RES *p; \
-ALLOC_ZVAL(*retval);\
+MAKE_STD_ZVAL(*retval);\
if (!obj->ptr) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
#define MYSQLI_GET_STMT(statusval) \
MYSQL_STMT *p; \
-ALLOC_ZVAL(*retval);\
+MAKE_STD_ZVAL(*retval);\
if (!obj->ptr) { \
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", obj->zo.ce->name);\
ZVAL_NULL(*retval);\
/* {{{ property link_client_version_read */
static int link_client_version_read(mysqli_object *obj, zval **retval TSRMLS_DC)
{
- ALLOC_ZVAL(*retval);
+ MAKE_STD_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);
+ MAKE_STD_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);
+ MAKE_STD_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);
+ MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_INITIALIZED);
ZVAL_STRING(*retval, MyG(error_msg), 1);
return SUCCESS;
MY_MYSQL *mysql;
my_ulonglong rc;
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
{
MYSQL_RES *p;
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
MYSQL_RES *p;
ulong *ret;
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MYSQL_RES *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
{
MY_STMT *p;
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MY_STMT*)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
MY_STMT *p;
my_ulonglong rc;
- ALLOC_ZVAL(*retval);
+ MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
p = (MY_STMT *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
/* }}} */
const 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}
+ {"affected_rows", sizeof("affected_rows") - 1, link_affected_rows_read, NULL},
+ {"client_info", sizeof("client_info") - 1, link_client_info_read, NULL},
+ {"client_version", sizeof("client_version") - 1, link_client_version_read, NULL},
+ {"connect_errno", sizeof("connect_errno") - 1, link_connect_errno_read, NULL},
+ {"connect_error", sizeof("connect_error") - 1, link_connect_error_read, NULL},
+ {"errno", sizeof("errno") - 1, link_errno_read, NULL},
+ {"error", sizeof("error") - 1, link_error_read, NULL},
+ {"field_count", sizeof("field_count") - 1, link_field_count_read, NULL},
+ {"host_info", sizeof("host_info") - 1, link_host_info_read, NULL},
+ {"info", sizeof("info") - 1, link_info_read, NULL},
+ {"insert_id", sizeof("insert_id") - 1, link_insert_id_read, NULL},
+ {"server_info", sizeof("server_info") - 1, link_server_info_read, NULL},
+ {"server_version", sizeof("server_version") - 1, link_server_version_read, NULL},
+ {"sqlstate", sizeof("sqlstate") - 1, link_sqlstate_read, NULL},
+ {"protocol_version",sizeof("protocol_version") - 1, link_protocol_version_read, NULL},
+ {"thread_id", sizeof("thread_id") - 1, link_thread_id_read, NULL},
+ {"warning_count", sizeof("warning_count") - 1, link_warning_count_read, NULL},
+ {NULL, 0, NULL, NULL}
};
+/* should not be const, as it is patched during runtime */
+zend_property_info mysqli_link_property_info_entries[] = {
+ {ZEND_ACC_PUBLIC, "affected_rows", sizeof("affected_rows") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "client_info", sizeof("client_info") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "client_version", sizeof("client_version") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "connect_errno", sizeof("connect_errno") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "connect_error", sizeof("connect_error") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "errno", sizeof("errno") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "error", sizeof("error") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "field_count", sizeof("field_count") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "host_info", sizeof("host_info") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "info", sizeof("info") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "insert_id", sizeof("insert_id") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "server_info", sizeof("server_info") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "server_version", sizeof("server_version") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "sqlstate", sizeof("sqlstate") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "protocol_version", sizeof("protocol_version")-1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "thread_id", sizeof("thread_id") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "warning_count", sizeof("warning_count") - 1, 0, NULL, 0, NULL},
+ {0, NULL, 0, 0, NULL, 0, NULL}
+};
+
+
const 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}
+ {"current_field",sizeof("current_field")-1, result_current_field_read, NULL},
+ {"field_count", sizeof("field_count") - 1, result_field_count_read, NULL},
+ {"lengths", sizeof("lengths") - 1, result_lengths_read, NULL},
+ {"num_rows", sizeof("num_rows") - 1, result_num_rows_read, NULL},
+ {"type", sizeof("type") - 1, result_type_read, NULL},
+ {NULL, 0, NULL, NULL}
+};
+
+zend_property_info mysqli_result_property_info_entries[] = {
+ {ZEND_ACC_PUBLIC, "current_field", sizeof("current_field")-1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "field_count", sizeof("field_count") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "lengths", sizeof("lengths") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "num_rows", sizeof("num_rows") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "type", sizeof("type") - 1, 0, NULL, 0, NULL},
+ {0, NULL, 0, 0, NULL, 0, NULL}
};
const 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}
+ {"affected_rows", sizeof("affected_rows")-1,stmt_affected_rows_read, NULL},
+ {"insert_id", sizeof("insert_id") - 1, stmt_insert_id_read, NULL},
+ {"num_rows", sizeof("num_rows") - 1, stmt_num_rows_read, NULL},
+ {"param_count", sizeof("param_count") - 1, stmt_param_count_read, NULL},
+ {"field_count", sizeof("field_count") - 1, stmt_field_count_read, NULL},
+ {"errno", sizeof("errno") - 1, stmt_errno_read, NULL},
+ {"error", sizeof("error") - 1, stmt_error_read, NULL},
+ {"sqlstate", sizeof("sqlstate") - 1, stmt_sqlstate_read, NULL},
+ {"id", sizeof("id") - 1, stmt_id_read, NULL},
+ {NULL, 0, NULL, NULL}
+};
+
+
+zend_property_info mysqli_stmt_property_info_entries[] = {
+ {ZEND_ACC_PUBLIC, "affected_rows", sizeof("affected_rows") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "insert_id", sizeof("insert_id") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "num_rows", sizeof("num_rows") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "param_count",sizeof("param_count") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "field_count",sizeof("field_count") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "errno", sizeof("errno") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "error", sizeof("error") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "sqlstate", sizeof("sqlstate") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "id", sizeof("id") - 1, 0, NULL, 0, NULL},
+ {0, NULL, 0, 0, NULL, 0, NULL}
};
/*
/* {{{ mysqli_warning_property_entries */
const 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}
+ {"message", sizeof("message") - 1, mysqli_warning_message, NULL},
+ {"sqlstate", sizeof("sqlstate") - 1, mysqli_warning_sqlstate, NULL},
+ {"errno", sizeof("errno") - 1, mysqli_warning_errno, NULL},
+ {NULL, 0, NULL, NULL}
};
/* }}} */
+/* {{{ mysqli_warning_property_info_entries */
+zend_property_info mysqli_warning_property_info_entries[] = {
+ {ZEND_ACC_PUBLIC, "message", sizeof("message") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "sqlstate", sizeof("sqlstate") - 1, 0, NULL, 0, NULL},
+ {ZEND_ACC_PUBLIC, "errno", sizeof("errno") - 1, 0, NULL, 0, NULL},
+ {0, NULL, 0, 0, NULL, 0, NULL}
+};
+/* }}} */
+
+
/*
* Local variables:
* tab-width: 4
};
typedef struct _mysqli_property_entry {
- char *pname;
+ const char *pname;
+ size_t pname_length;
int (*r_func)(mysqli_object *obj, zval **retval TSRMLS_DC);
int (*w_func)(mysqli_object *obj, zval *value TSRMLS_DC);
} mysqli_property_entry;
extern const mysqli_property_entry mysqli_driver_property_entries[];
extern const mysqli_property_entry mysqli_warning_property_entries[];
+extern zend_property_info mysqli_link_property_info_entries[];
+extern zend_property_info mysqli_result_property_info_entries[];
+extern zend_property_info mysqli_stmt_property_info_entries[];
+extern zend_property_info mysqli_driver_property_info_entries[];
+extern zend_property_info mysqli_warning_property_info_entries[];
+
#ifdef MYSQLI_USE_MYSQLND
extern MYSQLND_ZVAL_PCACHE *mysqli_mysqlnd_zval_cache;
extern MYSQLND_QCACHE *mysqli_mysqlnd_qcache;
extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type);
extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC);
extern void php_mysqli_report_index(const 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;
#define MYSQLI_RETURN_LONG_LONG(__val) \
{ \
if ((__val) < LONG_MAX) { \
- RETURN_LONG((__val)); \
+ RETURN_LONG((long) (__val)); \
} else { \
char *ret; \
+ /* always used with my_ulonglong -> %llu */ \
int l = spprintf(&ret, 0, "%llu", (__val)); \
RETURN_STRINGL(ret, l, 0); \
} \
}
-#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
#ifdef MYSQLI_USE_MYSQLND
#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
php_mysqli_report_error(mysql_stmt_sqlstate(stmt), mysql_stmt_errno(stmt), mysql_stmt_error(stmt) 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);
-
void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect, zend_bool in_ctor);
#endif
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)
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);
+PHP_FUNCTION(mysqli_stmt_construct);
+PHP_FUNCTION(mysqli_result_construct);
+PHP_FUNCTION(mysqli_driver_construct);
+PHP_METHOD(mysqli_warning,__construct);
#endif /* PHP_MYSQLI_STRUCTS.H */
bool(true)
bool(true)
object(mysqli_stmt)#%d (%d) {
+ ["affected_rows"]=>
+ int(-1)
+ ["insert_id"]=>
+ int(0)
+ ["num_rows"]=>
+ int(0)
+ ["param_count"]=>
+ int(0)
+ ["field_count"]=>
+ int(1)
+ ["errno"]=>
+ int(0)
+ ["error"]=>
+ string(0) ""
+ ["sqlstate"]=>
+ string(5) "00000"
+ ["id"]=>
+ int(3)
}
bool(true)
bool(false)
[0]=>
unicode(1) "1"
}
-done!
\ No newline at end of file
+done!
var_dump($link);
$link = mysqli_init();
- var_dump($link);
+ /* @ is to supress 'Property access is not allowed yet' */
+ @var_dump($link);
$mysql = new mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS test_warnings");
echo "Done\n";
?>
--EXPECTF--
-object(mysqli)#%d (0) {
+object(mysqli)#%d (%d) {
+ ["affected_rows"]=>
+ int(0)
+ ["client_info"]=>
+ string(%d) "%s"
+ ["client_version"]=>
+ int(%d)
+ ["connect_errno"]=>
+ int(0)
+ ["connect_error"]=>
+ string(0) ""
+ ["errno"]=>
+ int(0)
+ ["error"]=>
+ string(0) ""
+ ["field_count"]=>
+ int(0)
+ ["host_info"]=>
+ string(42) "MySQL host info: Localhost via UNIX socket"
+ ["info"]=>
+ NULL
+ ["insert_id"]=>
+ int(0)
+ ["server_info"]=>
+ string(%d) "%s"
+ ["server_version"]=>
+ int(%d)
+ ["sqlstate"]=>
+ string(5) "00000"
+ ["protocol_version"]=>
+ int(10)
+ ["thread_id"]=>
+ int(%d)
+ ["warning_count"]=>
+ int(0)
}
-object(mysqli)#%d (0) {
+object(mysqli)#%d (%d) {
+ ["affected_rows"]=>
+ NULL
+ ["client_info"]=>
+ string(%d) "%s"
+ ["client_version"]=>
+ int(%d)
+ ["connect_errno"]=>
+ int(0)
+ ["connect_error"]=>
+ string(0) ""
+ ["errno"]=>
+ int(0)
+ ["error"]=>
+ string(0) ""
+ ["field_count"]=>
+ NULL
+ ["host_info"]=>
+ NULL
+ ["info"]=>
+ NULL
+ ["insert_id"]=>
+ NULL
+ ["server_info"]=>
+ NULL
+ ["server_version"]=>
+ NULL
+ ["sqlstate"]=>
+ NULL
+ ["protocol_version"]=>
+ NULL
+ ["thread_id"]=>
+ NULL
+ ["warning_count"]=>
+ NULL
}
-object(mysqli_warning)#%d (0) {
+object(mysqli_warning)#%d (%d) {
+ ["message"]=>
+ string(25) "Column 'a' cannot be null"
+ ["sqlstate"]=>
+ string(5) "HY000"
+ ["errno"]=>
+ int(1048)
}
Done
return FALSE;
}
}
-?>
+?>
\ No newline at end of file
printf("ok\n");
printf("\nClass variables:\n");
- $variables = get_class_vars(get_class($driver));
+ $variables = array_keys(get_class_vars(get_class($driver)));
sort($variables);
foreach ($variables as $k => $var)
printf("%s\n", $var);
printf("\nObject variables:\n");
- $variables = get_object_vars($driver);
+ $variables = array_keys(get_object_vars($driver));
foreach ($variables as $k => $var)
printf("%s\n", $var);
ok
Class variables:
+client_info
+client_version
+driver_version
+embedded
+reconnect
+report_mode
Object variables:
+client_info
+client_version
+driver_version
+embedded
+reconnect
+report_mode
Magic, magic properties:
driver->client_info = '%s'
Access to undefined properties:
driver->unknown = ''
-done!
\ No newline at end of file
+done!
Modifiers: '%d'
Parent Class: ''
Extension: 'mysqli'
-done!
\ No newline at end of file
+
+Inspecting property 'client_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'client_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'driver_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'embedded'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'reconnect'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'report_mode'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'client_info'
+Default property 'client_version'
+Default property 'driver_version'
+Default property 'embedded'
+Default property 'reconnect'
+Default property 'report_mode'
+done!
printf("ok\n");
printf("\nClass variables:\n");
- $variables = get_class_vars(get_class($mysqli));
+ $variables = array_keys(get_class_vars(get_class($mysqli)));
sort($variables);
foreach ($variables as $k => $var)
printf("%s\n", $var);
printf("\nObject variables:\n");
- $variables = get_object_vars($mysqli);
+ $variables = array_keys(get_object_vars($mysqli));
foreach ($variables as $k => $var)
printf("%s\n", $var);
ok
Class variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+protocol_version
+server_info
+server_version
+sqlstate
+thread_id
+warning_count
Object variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+server_info
+server_version
+sqlstate
+protocol_version
+thread_id
+warning_count
Magic, magic properties:
mysqli->affected_rows = '%s'/integer ('%s'/integer)
ok
Class variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+protocol_version
+server_info
+server_version
+sqlstate
+thread_id
+warning_count
Object variables:
+affected_rows
+client_info
+client_version
+connect_errno
+connect_error
+errno
+error
+field_count
+host_info
+info
+insert_id
+server_info
+server_version
+sqlstate
+protocol_version
+thread_id
+warning_count
Magic, magic properties:
mysqli->affected_rows = '%s'/integer ('%s'/integer)
require_once('reflection_tools.inc');
$class = new ReflectionClass('mysqli');
inspectClass($class);
- print "done!";
+ print "done!\n";
?>
--EXPECTF--
Inspecting class 'mysqli'
Modifiers: 256
Number of Parameters: 0
Number of Required Parameters: 0
+
+Inspecting property 'affected_rows'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'client_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'client_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'connect_errno'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'connect_error'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'errno'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'error'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'field_count'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'host_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'insert_id'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'protocol_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'server_info'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'server_version'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'sqlstate'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'thread_id'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'warning_count'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'affected_rows'
+Default property 'client_info'
+Default property 'client_version'
+Default property 'connect_errno'
+Default property 'connect_error'
+Default property 'errno'
+Default property 'error'
+Default property 'field_count'
+Default property 'host_info'
+Default property 'info'
+Default property 'insert_id'
+Default property 'protocol_version'
+Default property 'server_info'
+Default property 'server_version'
+Default property 'sqlstate'
+Default property 'thread_id'
+Default property 'warning_count'
done!
+
printf("\nClass variables:\n");
- $variables = get_class_vars(get_class($mysqli_result));
+ $variables = array_keys(get_class_vars(get_class($mysqli_result)));
sort($variables);
foreach ($variables as $k => $var)
printf("%s\n", $var);
printf("\nObject variables:\n");
- $variables = get_object_vars($mysqli_result);
+ $variables = array_keys(get_object_vars($mysqli_result));
foreach ($variables as $k => $var)
printf("%s\n", $var);
ok
Class variables:
+current_field
+field_count
+lengths
+num_rows
+type
Object variables:
+current_field
+field_count
+lengths
+num_rows
+type
Magic, magic properties:
mysqli_result->current_field = '0'/integer ('0'/integer)
ok
Class variables:
+current_field
+field_count
+lengths
+num_rows
+type
Object variables:
+current_field
+field_count
+lengths
+num_rows
+type
Magic, magic properties:
mysqli_result->current_field = '0'/integer ('0'/integer)
Warning: mysqli_result::mysqli_result() expects parameter 2 to be long, Unicode string given in %s on line %d
Warning: mysqli_result::mysqli_result() expects parameter 1 to be mysqli, Unicode string given in %s on line %d
-done!
\ No newline at end of file
+done!
Modifiers: %d
Number of Parameters: 0
Number of Required Parameters: 0
-done!
\ No newline at end of file
+
+Inspecting property 'current_field'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'field_count'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'lengths'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'num_rows'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'type'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'current_field'
+Default property 'field_count'
+Default property 'lengths'
+Default property 'num_rows'
+Default property 'type'
+done!
printf("ok\n");
printf("\nClass variables:\n");
- $variables = get_class_vars(get_class($stmt));
+ $variables = array_keys(get_class_vars(get_class($stmt)));
sort($variables);
foreach ($variables as $k => $var)
printf("%s\n", $var);
printf("\nObject variables:\n");
- $variables = get_object_vars($stmt);
+ $variables = array_keys(get_object_vars($stmt));
foreach ($variables as $k => $var)
printf("%s\n", $var);
ok
Class variables:
+affected_rows
+errno
+error
+field_count
+id
+insert_id
+num_rows
+param_count
+sqlstate
Object variables:
+affected_rows
+insert_id
+num_rows
+param_count
+field_count
+errno
+error
+sqlstate
+id
Magic, magic properties:
ok
Class variables:
+affected_rows
+errno
+error
+field_count
+id
+insert_id
+num_rows
+param_count
+sqlstate
Object variables:
+affected_rows
+insert_id
+num_rows
+param_count
+field_count
+errno
+error
+sqlstate
+id
Magic, magic properties:
Prepare using the constructor:
Warning: mysqli_stmt::mysqli_stmt() expects parameter 2 to be binary string, object given in %s on line %d
-done!
\ No newline at end of file
+done!
require_once('reflection_tools.inc');
$class = new ReflectionClass('mysqli_warning');
inspectClass($class);
- print "done!";
+ print "done!\n";
?>
--EXPECTF--
Inspecting class 'mysqli_warning'
Modifiers: %d
Number of Parameters: 0
Number of Required Parameters: 0
-done!
\ No newline at end of file
+
+Inspecting property 'errno'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'message'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+
+Inspecting property 'sqlstate'
+isPublic: yes
+isPrivate: no
+isProtected: no
+isStatic: no
+isDefault: yes
+Modifiers: 256
+Default property 'errno'
+Default property 'message'
+Default property 'sqlstate'
+done!
ini_set('mysqli.default_host', $host);
if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) {
- printf("[008] Usage of mysqli.default_host failed\n") ;
+ printf("[012] Failed to create mysqli object\n");
} else {
- $mysqli->close();
+ // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection!
+ // We had long discussions on this and found that the ext/mysqli API as
+ // such is broken. As we can't fix it, we document how it has behaved from
+ // the first day on. And that's: no connection.
+ if (NULL !== ($tmp = @$mysqli->query('SELECT 1'))) {
+ printf("[013] There shall be no connection!\n");
+ $mysqli->close();
+ }
}
if ($IS_MYSQLND) {
ini_set('mysqli.default_host', 'p:' . $host);
- if (!is_object($mysqli = new mysqli()) || (0 !== mysqli_connect_errno())) {
- printf("[008b] Usage of mysqli.default_host failed\n") ;
+ if (!is_object($mysqli = new mysqli())) {
+ // Due to an API flaw this shall not connect
+ printf("[010] Failed to create mysqli object\n");
} else {
- $mysqli->close();
+ // There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection!
+ // We had long discussions on this and found that the ext/mysqli API as
+ // such is broken. As we can't fix it, we document how it has behaved from
+ // the first day on. And that's: no connection.
+ if (NULL !== ($tmp = @$mysqli->query('SELECT 1'))) {
+ printf("[011] There shall be no connection!\n");
+ $mysqli->close();
+ }
}
}
?>
--EXPECTF--
Warning: mysqli::mysqli(): (%d/%d): Access denied for user '%sunknown%s'@'%s' (using password: %s) in %s on line %d
-
-Warning: mysqli::close(): Couldn't fetch mysqli in %s on line %d
... and now Exceptions
Access denied for user '%s'@'%s' (using password: %s)
done!
\ No newline at end of file
$expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true;
$expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true;
$expected_constants['MYSQLI_DEBUG_TRACE_ENABLED'] = true;
-
+
} else {
$version = mysqli_get_client_version();
}
if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) {
- $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;
+ $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;
}
if ($version > 50002) {
if (!function_exists('mysqli_debug'))
die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+ die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+ die("skip: debug functionality not enabled");
?>
--FILE--
<?php
if (!function_exists('mysqli_debug'))
die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+ die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+ die("skip: debug functionality not enabled");
?>
--FILE--
<?php
if (!function_exists('mysqli_debug'))
die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+ die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+ die("skip: debug functionality not enabled");
?>
--FILE--
<?php
if (!function_exists('mysqli_debug'))
die("skip mysqli_debug() not available");
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+ die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+ die("skip: debug functionality not enabled");
+
require_once('connect.inc');
if (!$IS_MYSQLND || ($MYSQLND_VERSION < 940))
die("skip needs mysqlnd version/revision 940+");
if (!function_exists('mysqli_debug'))
die("skip: mysqli_debug() not available");
+
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+ die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+ die("skip: debug functionality not enabled");
?>
--FILE--
<?php
if (!function_exists('mysqli_debug'))
die("skip mysqli_debug() not available");
+if (!defined('MYSQLI_DEGBUG_TRACE_ENABLED'))
+ die("skip: can't say for sure if mysqli_debug works");
+
+if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
+ die("skip: debug functionality not enabled");
+
if (!$IS_MYSQLND)
die("skip mysqlnd only test");
?>
Warning: mysqli_kill(): processid should have positive value in %s on line %d
string(%d) "%s"
bool(false)
-object(mysqli)#%d (0) {
+object(mysqli)#%d (%d) {
+ ["affected_rows"]=>
+ int(-1)
+ ["client_info"]=>
+ string(%d) "%s"
+ ["client_version"]=>
+ int(%d)
+ ["connect_errno"]=>
+ int(0)
+ ["connect_error"]=>
+ string(0) ""
+ ["errno"]=>
+ int(2006)
+ ["error"]=>
+ string(26) "MySQL server has gone away"
+ ["field_count"]=>
+ int(0)
+ ["host_info"]=>
+ string(42) "MySQL host info: Localhost via UNIX socket"
+ ["info"]=>
+ string(38) "Records: 6 Duplicates: 0 Warnings: 0"
+ ["insert_id"]=>
+ int(0)
+ ["server_info"]=>
+ string(%d) "%s"
+ ["server_version"]=>
+ int(%d)
+ ["sqlstate"]=>
+ string(5) "HY000"
+ ["protocol_version"]=>
+ int(10)
+ ["thread_id"]=>
+ int(%d)
+ ["warning_count"]=>
+ int(0)
}
Warning: mysqli_kill(): processid should have positive value in %s on line %d
}
Warning: mysqli_kill(): processid should have positive value in %s on line %d
-done!
\ No newline at end of file
+done!
--TEST--
mysqli_options()
--SKIPIF--
-<?php
+<?php
require_once('skipif.inc');
-require_once('skipifemb.inc');
+require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include "connect.inc";
+
+/*
+TODO: ext/mysqli might lack support for those options which are available
+with the libmysql C call mysql_options(). Not sure which of them make
+sense to have in PHP and not even sure which of them might be available
+already through other measures.
+
+ MYSQL_OPT_COMPRESS (argument: not used) --> Andrey/Ulf: bug, should be added
+ ? MYSQL_OPT_NAMED_PIPE (argument: not used) ?
+ MYSQL_OPT_READ_TIMEOUT (argument type: unsigned int *) --> Andrey/Ulf: bug, should be added
+ MYSQL_OPT_RECONNECT (argument type: my_bool *) --> Andrey/Ulf: might be security risk to have
+ MYSQL_OPT_SSL_VERIFY_SERVER_CERT (argument type: my_bool *) --> Andrey/Ulf: might be security risk to have
+ MYSQL_OPT_WRITE_TIMEOUT (argument type: unsigned int *) --> Andrey/Ulf: bug, should be added
+ MYSQL_REPORT_DATA_TRUNCATION (argument type: my_bool *) --> Andrey: bug, although truncation might only happen with libmysql not with mysqlnd
+ MYSQL_SECURE_AUTH (argument type: my_bool *) --> Ulf: let's say deprecated, no bug
+ ? MYSQL_SET_CHARSET_DIR (argument type: char *) ?
+ MYSQL_SHARED_MEMORY_BASE_NAME (argument type: char *)
+*/
+
$valid_options = array( MYSQLI_READ_DEFAULT_GROUP, MYSQLI_READ_DEFAULT_FILE,
MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE,
MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_GROUP,
}
}
- var_dump($link);
+ @var_dump($link);
if (NULL === ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
printf("[026] Expecting not NULL, got %s/%s\n", gettype($tmp), $tmp);
--EXPECTF--
Warning: mysqli_real_connect(): (%d/%d): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d
object(mysqli)#%d (%d) {
+ ["affected_rows"]=>
+ NULL
+ ["client_info"]=>
+ string(%d) "%s"
+ ["client_version"]=>
+ int(%d)
+ ["connect_errno"]=>
+ int(%d)
+ ["connect_error"]=>
+ string(%d) "%s"
+ ["errno"]=>
+ int(%d)
+ ["error"]=>
+ string(%d) "%s"
+ ["field_count"]=>
+ NULL
+ ["host_info"]=>
+ NULL
+ ["info"]=>
+ NULL
+ ["insert_id"]=>
+ NULL
+ ["server_info"]=>
+ NULL
+ ["server_version"]=>
+ NULL
+ ["sqlstate"]=>
+ NULL
+ ["protocol_version"]=>
+ NULL
+ ["thread_id"]=>
+ NULL
+ ["warning_count"]=>
+ NULL
}
done!
$references[$idx++] = &$res;
mysqli_free_result($res);
- debug_zval_dump($references);
+ @debug_zval_dump($references);
if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) ||
!($res = mysqli_use_result($link)))
unicode(1) "a" { 0061 } refcount(1)
}
}
-done!
\ No newline at end of file
+done!
print "done!";
?>
--EXPECTF--
-done!
\ No newline at end of file
+done!
if (errstr) {
DBG_ERR_FMT("[%d] %.64s (trying to connect via %s)", errcode, errstr, conn->scheme);
- SET_CLIENT_ERROR(conn->error_info, errcode, UNKNOWN_SQLSTATE, errstr);
-
+ SET_CLIENT_ERROR(conn->error_info, errcode? errcode:CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, errstr);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "[%d] %.64s (trying to connect via %s)", errcode, errstr, conn->scheme);
mnd_efree(errstr);
#define SET_CLIENT_ERROR(error_info, a, b, c) \
{ \
- error_info.error_no = a; \
- strlcpy(error_info.sqlstate, b, sizeof(error_info.sqlstate)); \
- strlcpy(error_info.error, c, sizeof(error_info.error)); \
+ error_info.error_no = (a); \
+ strlcpy(error_info.sqlstate, (b), sizeof(error_info.sqlstate)); \
+ strlcpy(error_info.error, (c), sizeof(error_info.error)); \
}
#define SET_STMT_ERROR(stmt, a, b, c) SET_CLIENT_ERROR(stmt->error_info, a, b, c)