I'm moving my code from using mysql in PHP to mysqli. In order to get the mysqli get_result() function to work I need to install mysqlnd as said here on SO. This involves removing the existing php-mysql extension, and now I just want to make sure (those of you who did this) that once I remove the mysql with:

yum remove php-mysql

and install mysqlnd with:

yum install php-mysqlnd

the other code (there's a lot of existing codebase) that uses mysql will still work?

My PHP Version is 5.3.27

有帮助吗?

解决方案 2

I would like to generally answer that NO it's not safe to just remove php-mysql and install php-mysqlnd, especially if you're not "a server guy". Because once I removed php-mysql I removed phpmyadmin along with it and that was quite a disaster.

I ended up (with help of Rackspace server guys) with upgrading my PHP to 5.4 (can't go to 5.5 yet until I convert all my code to use mysqli) and then manually forcing the install of php54-mysqlnd-5.4.17-1.ius.el6.x86_64 (http://dev.mysql.com/downloads/connector/php-mysqlnd/), because of the error while trying to do it "the normal way" Error: php54-mysql conflicts with php54-mysqlnd-5.4.17-1.ius.el6.x86_64. Hope this helps someone.

其他提示

With both of php-mysql and php-mysqlnd you have mysql, mysqli and PDO drivers all together. If you just need mysqli driver you already have it with php-mysql.

However if you want migrate to MySQL native driver According to documentation you must pay attention to these:

--The new mysqlnd library necessitates the use of MySQL 4.1's newer 41-byte password format. Continued use of the old 16-byte passwords will cause mysql_connect() and similar functions to emit the error, "mysqlnd cannot connect to MySQL 4.1+ using old authentication." The

--new mysqlnd library does not read mysql configuration files (my.cnf/my.ini), as the older libmysqlclient library does. If your code relies on settings in the configuration file, you can load it explicitly with the mysqli_options() function. Note that this means the PDO specific constants PDO::MYSQL_ATTR_READ_DEFAULT_FILE and PDO::MYSQL_ATTR_READ_DEFAULT_GROUP are not defined if MySQL support in PDO is compiled with mysqlnd.

Generally you don't have any problem to migrate from MySQL driver to MySQL native driver. Also it recommended to use php-mysqlnd instead of php-mysql.

Also be aware of mysqlnd returning number as numbers, while libmysqlclient (php-mysql) returns all types as string.

So if you use ===, it may give unexpected behavior.

Had a case with mysqlnd in the dev-envirement, and libmysqlclient in the production-envirement, got a few bugs where I compared a string value and an integer value, but on the dev server they was both integers.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top