summaryrefslogtreecommitdiff
path: root/ext/mysql/php_mysql.c
diff options
context:
space:
mode:
authorSean Bright <elixer@php.net>2001-01-31 22:04:30 +0000
committerSean Bright <elixer@php.net>2001-01-31 22:04:30 +0000
commit31c8104dc66064015a867447a631c77610bc8f7e (patch)
treef4311735b3b81bb80463fb6d91d5d57ed1ef3bad /ext/mysql/php_mysql.c
parent0611acb910003f86287f0a0e0163f42bce9b1e62 (diff)
downloadphp-git-31c8104dc66064015a867447a631c77610bc8f7e.tar.gz
Added the mysql_get_*_info() functions.
# If anyone knows of a version of mysql lower then 3.20.32 that implements # all 3 of these functions, please change the conditionals. @- Added mysql_get_client_info(), mysql_get_server_info(), @ mysql_get_proto_info(), and mysql_get_host_info() functions. (Sean)
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r--ext/mysql/php_mysql.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 0acac78eb3..f53d8ef028 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -73,6 +73,10 @@ static int le_result, le_link, le_plink;
# endif
#endif
+#if MYSQL_VERSION_ID >= 32032
+#define HAVE_GETINFO_FUNCS
+#endif
+
#if MYSQL_VERSION_ID > 32133 || defined(FIELD_TYPE_TINY)
#define MYSQL_HAS_TINY
#endif
@@ -132,6 +136,12 @@ function_entry mysql_functions[] = {
PHP_FE(mysql_field_type, NULL)
PHP_FE(mysql_field_flags, NULL)
PHP_FE(mysql_escape_string, NULL)
+#ifdef HAVE_GETINFO_FUNCS
+ PHP_FE(mysql_get_client_info, NULL)
+ PHP_FE(mysql_get_host_info, NULL)
+ PHP_FE(mysql_get_proto_info, NULL)
+ PHP_FE(mysql_get_server_info, NULL)
+#endif
/* for downwards compatability */
PHP_FALIAS(mysql, mysql_db_query, NULL)
@@ -689,6 +699,115 @@ PHP_FUNCTION(mysql_select_db)
}
/* }}} */
+#ifdef HAVE_GETINFO_FUNCS
+
+/* {{{ proto string mysql_get_client_info([int link_identifier])
+ Returns a string that represents the client library version */
+PHP_FUNCTION(mysql_get_client_info)
+{
+ if (ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
+
+ RETURN_STRING(mysql_get_client_info(),1);
+}
+/* }}} */
+
+/* {{{ proto string mysql_get_host_info([int link_identifier])
+ Returns a string describing the type of connection in use, including the
+ server host name */
+PHP_FUNCTION(mysql_get_host_info)
+{
+ zval **mysql_link;
+ int id;
+ MYSQL *mysql;
+ MySLS_FETCH();
+
+ switch(ZEND_NUM_ARGS()) {
+ case 0:
+ id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
+ CHECK_LINK(id);
+ break;
+ case 1:
+ if (zend_get_parameters_ex(1,&mysql_link)==FAILURE) {
+ RETURN_FALSE;
+ }
+ id = -1;
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
+
+ RETURN_STRING(mysql_get_host_info(mysql),1);
+}
+/* }}} */
+
+/* {{{ proto int mysql_get_proto_info([int link_identifier])
+ Returns the protocol version used by current connection */
+PHP_FUNCTION(mysql_get_proto_info)
+{
+ zval **mysql_link;
+ int id;
+ MYSQL *mysql;
+ MySLS_FETCH();
+
+ switch(ZEND_NUM_ARGS()) {
+ case 0:
+ id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
+ CHECK_LINK(id);
+ break;
+ case 1:
+ if (zend_get_parameters_ex(1,&mysql_link)==FAILURE) {
+ RETURN_FALSE;
+ }
+ id = -1;
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
+
+ RETURN_LONG(mysql_get_proto_info(mysql));
+}
+/* }}} */
+
+/* {{{ proto string mysql_get_server_info([int link_identifier])
+ Returns a string that represents the server version number */
+PHP_FUNCTION(mysql_get_server_info)
+{
+ zval **mysql_link;
+ int id;
+ MYSQL *mysql;
+ MySLS_FETCH();
+
+ switch(ZEND_NUM_ARGS()) {
+ case 0:
+ id = php_mysql_get_default_link(INTERNAL_FUNCTION_PARAM_PASSTHRU MySLS_CC);
+ CHECK_LINK(id);
+ break;
+ case 1:
+ if (zend_get_parameters_ex(1,&mysql_link)==FAILURE) {
+ RETURN_FALSE;
+ }
+ id = -1;
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ break;
+ }
+
+ ZEND_FETCH_RESOURCE2(mysql, MYSQL *, mysql_link, id, "MySQL-Link", le_link, le_plink);
+
+ RETURN_STRING(mysql_get_server_info(mysql),1);
+}
+/* }}} */
+
+#endif
/* {{{ proto int mysql_create_db(string database_name [, int link_identifier])
Create a MySQL database */