0

I am building an application which includes prepared mysqli statements. I use Object oriented PHP. The day before yesterday everything was working great. Yesterday I updated my Ubuntu machine (which I currently use as web server). Today I was trying again and poof! there was an error. "call to undefined method mysqli_stmt::get_result()" So I went to the internet and found out that get_result needs the mysqlnd library. So I used the following to check if the library is included:

if (extension_loaded('mysqlnd')) {
    echo 'extension mysqlnd is loaded'; //works
}else{
   echo  'extension is not loading';
}  

And indeed I got the message that the extension is not loading. What I want to do now is try to load the library, but how do I do that?

The best I could found was this:

http://php.net/manual/en/mysqlnd.install.php

But even with some trial and error I can't get this to work.

Question: How do I load the mysqlnd library?

  • Check your php.ini file, the update may have replaced any changes made to it. – gen_Eric Jan 22 '15 at 16:08
  • `mysqlnd` is not an extension, you need to compile PHP, and pass the correct options to `./configure`, or remove the current `php-mysql` package, and reinstall it with one that uses the native driver. check which driver is being used by doing `php -m | grep mysqlnd` or `php -i | grep mysqlnd` – Elias Van Ootegem Jan 22 '15 at 16:09
  • 1
    possible duplicate of [How to enable mysqlnd for php?](http://stackoverflow.com/questions/13159518/how-to-enable-mysqlnd-for-php) – Elias Van Ootegem Jan 22 '15 at 16:14
  • Ok, first I did not installed php-mysql I only have php5-mysql installed. Do I have to install the other too? both **php -m | grep mysqlnd** and **php -i | grep mysqlnd** does not return anything. –  Jan 22 '15 at 16:15
  • @EliasVanOotegem I followed your link and now I get a result from php -i | grep mysqlnd, but it is still not working –  Jan 22 '15 at 16:23
  • @user3892683: You can't actually _see_ `mysqlnd` from within your PHP code (well, not quite). It's the MySQL driver PHP uses internally in its extensions (`PDO` uses `mysqlnd` or the old mysql driver but the code _you_ write doesn't change) – Elias Van Ootegem Jan 22 '15 at 16:24
  • A simple restart did the trick of course after following the link! Thans for your help! –  Jan 22 '15 at 16:24

1 Answers1

0

You cannot load mysqlnd library. This is a special PHP extension that cannot be enabled/disabled by PHP ini config and the extension doesn't expose any functionality by itself.

Mysqlnd is a client library for connecting to MySQL servers. It's actually a C library implemented as a PHP extension. It means that you can use it when writing another PHP extension in C, e.g. mysqli, PDO_MySQL or php_mysql.

The only way it can be enabled/disabled is during the compilation of PHP source code via one of the compilation flags for either mysqli or PDO_MySQL extensions. You need to recompile your PHP distributable with the appropriate flag (the flag is set to On by default, so if you are missing some functions in mysqli it means your PHP was compiled with libmysql instead).

Dharman
  • 30,962
  • 25
  • 85
  • 135