php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #41083 mysql_ping cann't work
Submitted: 2007-04-14 01:06 UTC Modified: 2007-08-17 09:51 UTC
From: xiaojb at gmail dot com Assigned: georg (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.1 OS: RedHat
Private report: No CVE-ID: None
 [2007-04-14 01:06 UTC] xiaojb at gmail dot com
Description:
------------
if mysql server is 5.0.13 and later, mysql client MUST set option "MYSQL_OPT_RECONNECT" to TRUE, then mysql_ping will work.

http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html

www@www215 /usr/local/src/php-5.2.1$ diff ext/mysql/php_mysql.c /tmp/php_mysql.c 
674a675,677
> #if MYSQL_VERSION_ID > 50012
>                       mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, "1");
> #endif
779a783,785
> #if MYSQL_VERSION_ID > 50012
>               mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, "1");
> #endif
www@www215 /usr/local/src/php-5.2.1$ diff -u ext/mysql/php_mysql.c /tmp/php_mysql.c 
--- ext/mysql/php_mysql.c       2007-01-01 17:36:03.000000000 +0800
+++ /tmp/php_mysql.c    2007-04-14 08:39:30.000000000 +0800
@@ -672,6 +672,9 @@
                        mysql->active_result_id = 0;
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                        mysql_init(&mysql->conn);
+#if MYSQL_VERSION_ID > 50012
+                       mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, "1");
+#endif
 
                        if (connect_timeout != -1)
                                mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
@@ -777,6 +780,9 @@
                mysql->active_result_id = 0;
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                mysql_init(&mysql->conn);
+#if MYSQL_VERSION_ID > 50012
+               mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, "1");
+#endif
 
                if (connect_timeout != -1)
                                mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-14 01:15 UTC] xiaojb at gmail dot com
if mysql server is 5.0.13 and later, mysql client MUST set option
"MYSQL_OPT_RECONNECT" to TRUE, then mysql_ping will work.

http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html

www@www215 /usr/local/src/php-5.2.1$ diff -u ext/mysql/php_mysql.c
/tmp/php_mysql.c 
--- ext/mysql/php_mysql.c       2007-01-01 17:36:03.000000000 +0800
+++ /tmp/php_mysql.c    2007-04-14 08:39:30.000000000 +0800
@@ -672,6 +672,9 @@
                        mysql->active_result_id = 0;
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                        mysql_init(&mysql->conn);
+#if MYSQL_VERSION_ID > 50012
+                       mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT,
"1");
+#endif
 
                        if (connect_timeout != -1)
                                mysql_options(&mysql->conn,
MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
@@ -777,6 +780,9 @@
                mysql->active_result_id = 0;
 #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
                mysql_init(&mysql->conn);
+#if MYSQL_VERSION_ID > 50012
+               mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, "1");
+#endif
 
                if (connect_timeout != -1)
                                mysql_options(&mysql->conn,
MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
 [2007-04-14 10:19 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2007-04-23 09:25 UTC] tony2001@php.net
Reverted and reclassified as docu problem.
 [2007-08-17 09:51 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Since MySQL 5.0.13, automatic reconnection feature is disabled."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 15:01:33 2025 UTC