Skip to content

Commit bc19dd6

Browse files
author
Jan Lehnardt
committed
- add mysql_info function
1 parent 1711643 commit bc19dd6

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

ext/mysql/php_mysql.c

+30
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ function_entry mysql_functions[] = {
166166
PHP_FE(mysql_get_proto_info, NULL)
167167
PHP_FE(mysql_get_server_info, NULL)
168168
#endif
169+
170+
PHP_FE(mysql_info, NULL)
169171

170172
/* for downwards compatability */
171173
PHP_FALIAS(mysql, mysql_db_query, NULL)
@@ -909,6 +911,34 @@ PHP_FUNCTION(mysql_get_server_info)
909911
}
910912
/* }}} */
911913

914+
/* {{{ proto string mysql_info([int link_identifier])
915+
Returns a string containing information about the most recent query */
916+
PHP_FUNCTION(mysql_info)
917+
{
918+
zval **mysql_link;
919+
int id;
920+
char *str;
921+
php_mysql_conn *mysql;
922+
923+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &mysql_link) == FAILURE) {
924+
return;
925+
}
926+
927+
if (ZEND_NUM_ARGS() == 0) {
928+
id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU);
929+
CHECK_LINK(id);
930+
}
931+
932+
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink);
933+
934+
if (str = mysql_info(&mysql->conn)) {
935+
RETURN_STRING(str,1);
936+
} else {
937+
RETURN_FALSE;
938+
}
939+
}
940+
/* }}} */
941+
912942
/* {{{ proto int mysql_thread_id([int link_identifier])
913943
Returns the thread id of current connection */
914944
PHP_FUNCTION(mysql_thread_id)

ext/mysql/php_mysql.h

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ PHP_FUNCTION(mysql_get_client_info);
8686
PHP_FUNCTION(mysql_get_host_info);
8787
PHP_FUNCTION(mysql_get_proto_info);
8888
PHP_FUNCTION(mysql_get_server_info);
89+
PHP_FUNCTION(mysql_info);
8990
PHP_FUNCTION(mysql_stat);
9091
PHP_FUNCTION(mysql_thread_id);
9192
PHP_FUNCTION(mysql_character_set_name);

0 commit comments

Comments
 (0)