What is the PDO equivalent of:
mysqli_stat($dbConn);
P.S. I use it to (get a message to) make sure I am connected
What is the PDO equivalent of:
mysqli_stat($dbConn);
P.S. I use it to (get a message to) make sure I am connected
I cannot get credit for this answer. Someone posted the answer, but he/she latter deleted the entry.
Here's the (saved archived)
answer to your question:
$status = $conn->getAttribute(PDO::ATTR_CONNECTION_STATUS);
$pdo->getAttribute(PDO::ATTR_CONNECTION_STATUS) always return "127.0.0.1 via TCP/IP" even if i stop mysqld, to use:
if ($pdo->getAttribute(PDO::ATTR_SERVER_INFO)=='MySQL server has gone away')
{
$pdo=new PDO('mysql:host=127.0.0.1;port=3306;dbname=mydb;charset=UTF8', 'root', '', array(PDO::ATTR_PERSISTENT=>true));
}
you can use
$name = $conn->getAttribute(PDO::ATTR_DRIVER_NAME);