summaryrefslogtreecommitdiff
path: root/ext/mysql/php_mysql.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-04-14 10:19:10 +0000
committerAntony Dovgal <tony2001@php.net>2007-04-14 10:19:10 +0000
commita95ac253db52829ccd225736941343d244572538 (patch)
tree5c93e64295fc3270987748a08c30ad0a0c6453fb /ext/mysql/php_mysql.c
parenta927b7b19fe697a96b0323ae349a7928a7176fae (diff)
downloadphp-git-a95ac253db52829ccd225736941343d244572538.tar.gz
fix #41083 (mysql_ping() requires MYSQL_OPT_RECONNECT to be set since MySQL 5.0.13)
Diffstat (limited to 'ext/mysql/php_mysql.c')
-rw-r--r--ext/mysql/php_mysql.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c
index 636e80ef1b..f7791f2ece 100644
--- a/ext/mysql/php_mysql.c
+++ b/ext/mysql/php_mysql.c
@@ -482,6 +482,9 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#if MYSQL_VERSION_ID <= 32230
void (*handler) (int);
#endif
+#if MYSQL_VERSION_ID > 50012
+ my_bool my_true = 1;
+#endif
zend_bool free_host=0, new_link=0;
long connect_timeout;
@@ -590,8 +593,14 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
mysql_init(&mysql->conn);
- if (connect_timeout != -1)
+#if MYSQL_VERSION_ID > 50012
+ /* Reconnect has been off by default since MySQL 5.0.3;
+ this option is new in 5.0.13 and provides a way to set reconnection behavior explicitly. */
+ mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, (const char *)&my_true);
+#endif
+ if (connect_timeout != -1) {
mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+ }
if (mysql_real_connect(&mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
#else
@@ -707,8 +716,15 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
#if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
mysql_init(&mysql->conn);
- if (connect_timeout != -1)
- mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+#if MYSQL_VERSION_ID > 50012
+ /* Reconnect has been off by default since MySQL 5.0.3;
+ this option is new in 5.0.13 and provides a way to set reconnection behavior explicitly. */
+ mysql_options(&mysql->conn, MYSQL_OPT_RECONNECT, (const char *)&my_true);
+#endif
+
+ if (connect_timeout != -1) {
+ mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+ }
if (mysql_real_connect(&mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
#else