Hi,
I enclose the patch for ext/mysql/php_mysql.[ch]
(against PHP version 4.2.2 - for earlier version it also works)
that adds new PHP function - mysql_info().
This function exists in mysql library log time,
and is also defined in the PHP's version of libmysql.
I would like to have acces to this function in PHP,
since mysql_info() is the only way I can check result of
SQL command 'LOAD DATA LOCAL INFILE ...'.
mysql_info() would return a string e.g.:
Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
I can then know if there were any errors encountered.
Best regards,
(patch is below the signature - `diff -u ...`)
--
Piotr Klaban
--- php_mysql.c-orig Thu Feb 28 09:26:25 2002
+++ php_mysql.c Wed Aug 14 14:09:35 2002
@@ -164,6 +164,7 @@
PHP_FE(mysql_get_proto_info,
NULL)
PHP_FE(mysql_get_server_info,
NULL)
#endif
+ PHP_FE(mysql_info,
+ NULL)
/* for downwards compatability */
PHP_FALIAS(mysql, mysql_db_query, NULL)
@@ -907,6 +908,36 @@
/* }}} */
#endif
+
+/* {{{ proto string mysql_info([int link_identifier])
+ Returns information about the most recently executed query */
+PHP_FUNCTION(mysql_info)
+{
+ zval **mysql_link;
+ int id;
+ php_mysql_conn *mysql;
+
+ switch(ZEND_NUM_ARGS()) {
+ case 0:
+ id = MySG(default_link);
+ 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, php_mysql_conn *, mysql_link, id, "MySQL-Link",
+le_link, le_plink);
+
+ RETURN_STRING(mysql_info(&mysql->conn), 1);
+}
+/* }}} */
#if MYSQL_VERSION_ID < 40000
/* {{{ proto bool mysql_create_db(string database_name [, int link_identifier])
--- php_mysql.h-orig Thu Feb 28 09:26:26 2002
+++ php_mysql.h Wed Aug 14 14:09:40 2002
@@ -84,6 +84,7 @@
PHP_FUNCTION(mysql_get_host_info);
PHP_FUNCTION(mysql_get_proto_info);
PHP_FUNCTION(mysql_get_server_info);
+PHP_FUNCTION(mysql_info);
ZEND_BEGIN_MODULE_GLOBALS(mysql)
long default_link;
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php