Be consistent, add mysqli::stat property, as equivalent of mysqli_stat().

Fix for Bug #55859 mysqli->stat property access gives error
This commit is contained in:
Andrey Hristov 2011-10-06 11:25:05 +00:00
parent 5f6020bc4d
commit 26dd8c52c4

View File

@ -251,6 +251,37 @@ MYSQLI_MAP_PROPERTY_FUNC_STRING(link_sqlstate_read, mysql_sqlstate, MYSQLI_GET_M
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_thread_id_read, mysql_thread_id, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
MYSQLI_MAP_PROPERTY_FUNC_LONG(link_warning_count_read, mysql_warning_count, MYSQLI_GET_MYSQL(MYSQLI_STATUS_VALID), ulong, "%lu")
/* {{{ property link_stat_read */
static int link_stat_read(mysqli_object *obj, zval **retval TSRMLS_DC)\
{\
MY_MYSQL *mysql;
MAKE_STD_ZVAL(*retval);
CHECK_STATUS(MYSQLI_STATUS_VALID);
mysql = (MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr;
if (!mysql) {
ZVAL_NULL(*retval);
} else {
char * stat_msg;
#if defined(MYSQLI_USE_MYSQLND)
uint stat_msg_len;
if (mysqlnd_stat(mysql->mysql, &stat_msg, &stat_msg_len) == PASS) {
ZVAL_STRINGL(*retval, stat_msg, stat_msg_len, 0);
}
#else
if ((stat_msg = (char *) mysql_stat(mysql->mysql))) {
ZVAL_STRING(*retval, stat_msg, 1);
}
#endif
}
return SUCCESS;
}
/* }}} */
/* result properties */
/* {{{ property result_type_read */
@ -424,6 +455,7 @@ const mysqli_property_entry mysqli_link_property_entries[] = {
{"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},
{"stat", sizeof("stat") - 1, link_stat_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},
@ -447,6 +479,7 @@ const zend_property_info mysqli_link_property_info_entries[] = {
{ZEND_ACC_PUBLIC, "insert_id", sizeof("insert_id") - 1, -1, 0, NULL, 0, NULL},
{ZEND_ACC_PUBLIC, "server_info", sizeof("server_info") - 1, -1, 0, NULL, 0, NULL},
{ZEND_ACC_PUBLIC, "server_version", sizeof("server_version") - 1, -1, 0, NULL, 0, NULL},
{ZEND_ACC_PUBLIC, "stat", sizeof("stat") - 1, -1, 0, NULL, 0, NULL},
{ZEND_ACC_PUBLIC, "sqlstate", sizeof("sqlstate") - 1, -1, 0, NULL, 0, NULL},
{ZEND_ACC_PUBLIC, "protocol_version", sizeof("protocol_version")-1, -1, 0, NULL, 0, NULL},
{ZEND_ACC_PUBLIC, "thread_id", sizeof("thread_id") - 1, -1, 0, NULL, 0, NULL},