本文介绍了如何知道 MySQLnd 是否是活动驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个显而易见的问题,但我想确定一下.

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

我如何知道 MySQLnd 是否是活动驱动程序?

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

我正在运行 PHP 5.3 和 MySQL 5.1.37.在 phpinfo() 中列出了 mysqlnd 但仅此而已我无法确定我使用的是 MySQLnd 还是旧驱动程序...

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...

phpinfo() 输出的提取

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 $

我正在使用 PDO,而 PDO 驱动程序说 mysql...

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

推荐答案

如果您通过 mysqli 访问,这应该可以解决问题:

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

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

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

要检测其是否为活动的 PDO 驱动程序,请创建您的 MySQL PDO 对象:

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

这篇关于如何知道 MySQLnd 是否是活动驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 05:23