How to know if MySQLnd is the active driver?

Warning! This method is unreliable and does not work since PHP 8.1

If you are accessing via mysqli, this should do the trick:

<?php
$mysqlnd = function_exists('mysqli_fetch_all');

if ($mysqlnd) {
    echo 'mysqlnd enabled!';
}

To detect if its the active PDO driver, create your MySQL PDO object then:

if (strpos($pdo->getAttribute(PDO::ATTR_CLIENT_VERSION), 'mysqlnd') !== false) {
    echo 'PDO MySQLnd enabled!';
}

Leave a Comment