Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Maybe it's an obvious question, but I want to be sure.

How can i know if it MySQLnd is the active driver?

I'm runing PHP 5.3 and MySQL 5.1.37. In phpinfo() mysqlnd is listed but only with this I can't be sure if I'm using MySQLnd or the old driver...

Extract of phpinfo() output

mysql
MySQL Support   enabled
Active Persistent Links     0
Active Links    0
Client API version  mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $ 

mysqli
MysqlI Support  enabled
Client API library version  mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $
Active Persistent Links     0
Inactive Persistent Links   0
Active Links    26 

mysqlnd
mysqlnd enabled
Version     mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $ 

PDO
PDO support enabled
PDO drivers     mysql

pdo_mysql
PDO Driver for MySQL    enabled
Client API version  mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $ 

I'm using PDO, and PDO driver says mysql...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
406 views
Welcome To Ask or Share your Answers For Others

1 Answer

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!';
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...