mysql - PHP: mysql_ping - auto reconnect problem -


i'm working old complex piece of php code, relies on direct mysql access via mysql_* functions. code uses mysql_ping extensively, assumes each mysql_ping call reconnect in case finds out connection timed out. problem since mysql 5.0.something mysql_ping doesn't reconnect automatically. in doc's found need call mysql_options appropriate flag, there's no such function mysql_options. instead, there's mysqli_options literally can't switch mysqli_* now, it'd take way time. downgrading mysql not considered solution. ideas how fix that?

thanks

upon checking php manual found piece of code may handle db connection status:

<?php  $conn = mysql_connect('localhost','user','pass'); mysql_select_db('db',$conn);  if (!mysql_ping ($conn)) { //here major trick, have close connection (even though not working) recreate properly.    mysql_close($conn);    $conn = mysql_connect('localhost','user','pass');    mysql_select_db('db',$conn); }  //run queries knowing connection alive....  ?> 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -