My application is using the following code to detect mysql higher than 5. It works well with PHP 5.2, 5.3 and 5.4.
The trouble is with PHP 5.5 which uses mysqlnd by default so the script reports mysqlnd 5.0.11-dev - 20120503 - $Id: 40933630edef551dfaca71298a83fad8d03d62d4 $ and cannot detect MySQL properly. I need to make an exception for such version, but I don't know how to.
echo "<mysql>";
if(key_exists('mysql', $phpinfo))
{
if(key_exists('Client API version', $phpinfo['mysql']))
{
$t=explode(".", $phpinfo['mysql']['Client API version']);
if($t[0]>=5)
$ok=1;
else
$ok=0;
echo "<val>{$phpinfo['mysql']['Client API version']}</val><ok>$ok</ok>";
}
else
echo "<val></val><ok>0</ok>";
}
else
echo "<val></val><ok>0</ok>";
echo "</mysql>\n";
You shouldn't be using mysql
in 5.5. It is deprecated.
PHP functions that start with
mysql_
have been deprecated as of PHP 5.5.0. If you are in a position to do so, please consider updating your code to use the MySQLi or PDO extensions instead.
Anyway, use mysqli (which you seem to have in your question tags)
The phpinfo key is: $phpinfo['mysqli']['Client API header version']
rather than $phpinfo['mysql']['Client API version']
.