問題描述
出于某種原因,我們托管服務器上的 pdo_mysql PHP 擴展無法運行使用 MySQL 視圖的查詢,并顯示此錯誤消息.
<塊引用>SQLSTATE[HY000]: 一般錯誤:1615 準備好的語句需要重新準備
(有一個討論
由于 libmysql
以字符串形式返回數字類型,我使用 mysqlnd
和 nd_pdo_mysql
來獲取本機/嚴格數據,以便數字類型不作為字符串返回.
來自MySQL官網:https://dev.mysql.com/downloads/connector/php-mysqlnd/一個>
<塊引用>用于 PHP mysqlnd
的 MySQL 本地驅動程序是 PHP 腳本語言的 MySQL 客戶端庫 libmysql
的直接替代品.
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.
To connect to your MySQL server from PHP, there are two versions of drivers:
mysqlnd
libmysql
In order to connect to your MySQL server using mysqlnd
driver, you use the nd_pdo_mysql
extension, as seen in below screenshot.
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 Librarylibmysql
for the PHP script language.
這篇關于nd_pdo_mysql 和 pdo_mysql 擴展之間有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!