Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

php - What is the difference between the nd_pdo_mysql and pdo_mysql extensions?

For some reason the pdo_mysql PHP extension, on our hosted server, fails to run a query that uses a MySQL view, with this error message.

SQLSTATE[HY000]: General error: 1615 Prepared statement needs to be re-prepared

(There is a discussion on Bug #42041 Prepared-Statement fails when MySQL-Server under load, as well as numerous questions on Stack Overflow.)

For some reason, the query using the view runs just fine, if we switch to using the nd_pdo_mysql extension, which is for the MySQL Native Driver (mysqlnd).

What is the difference between pdo_mysql and nd_pdo_mysql? Why would one be chosen over the other one?

Thanks.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

To connect to your MySQL server from PHP, there are two versions of drivers:

  1. mysqlnd
  2. libmysql

In order to connect to your MySQL server using mysqlnd driver, you use the nd_pdo_mysql extension, as seen in below screenshot.

enter image description here

Since libmysql returns numeric types as strings, I use mysqlnd with nd_pdo_mysql in order to get native/strict data, so that numeric types are NOT returned as Strings.

From the MySQL official website: https://dev.mysql.com/downloads/connector/php-mysqlnd/

The MySQL native driver for PHP mysqlnd is a drop-in replacement for the MySQL Client Library libmysql for the PHP script language.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...