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!';
}
MySQLnd gone missing? How can I work with host provider?
The correct configure option would be --with-mysqli
for mysqlnd in mysqli and --with-pdo-mysql
for mysqlnd with PDO. Your PHP version has been compiled without mysqlnd or mysqlnd is not enabled (some hosting providers have an option to chose which extension you use e.g. cPanel). However, this would not show in phpinfo()
usually.
If your hosting provider changed the PHP version on you without you even knowing, it paints a bad picture of them. I would encourage you to change the hosting provider. It's unforgivable to offer PDO or mysqli without mysqlnd.
The PHP version you use should remain the same until you decide to upgrade. This is important because some versions contain breaking changes. Your PHP executable can't be silently upgraded without your knowledge as it might lead to your application breaking suddenly.
get_result() Doesn't Work even mysqlnd is enabled
To make this thing work, Enable nd_mysqli
in php extensions and disable mysqli
. This will work like charm!
Query method doesn't work - missing mysqlnd driver
A quite similar approach using call_user_func_array()
You can find some solutions in the Comments section on the manual page
I have no idea why mysqli require all this unnecessary toilsome stuff while PDO does it out of the box. Compare your soon-will-be code with this one:
function query($query, $params=NULL) {
$stmt = $this->pdo->prepare($query);
$stmt->execute($params);
return $stmt->fetchAll();
}
Related Topics
How to Use PHP to Dynamically Publish an Ical File to Be Read by Google Calendar
Print Newline in PHP in Single Quotes
Remove Diacritics from a String
Display Message Before Redirect to Other Page
PHP - Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by Wordpress
Getting Data with Utf-8 Charset from Mssql Server Using PHP Freetds Extension
How to Access PHP Session Variables from Jquery Function in a .Js File
Can't Concatenate 2 Arrays in PHP
Is PHP Str_Word_Count() Multibyte Safe
Selecting All Columns That Start with Xxx Using a Wildcard
Programmatically Access Currency Exchange Rates
Finding the PHP File (At Run Time) Where a Class Was Defined
Codeigniter - Why Use Xss_Clean
Rerouting All PHP Requests Through Index.Php
Setcookie() Does Not Set Cookie in Google Chrome
Remove Index.PHP in Codeigniter 2.1.0