問題描述
嘗試學習新東西 - 特別是嘗試選擇使用 MySQLi 還是 PDO 用于將來使用 MySQL 的項目 - 我偶然發現了 這個頁面 顯示了我可用的選項概覽.
Trying to learn something new - specifically trying to choose wether to use MySQLi or PDO for future projects when working with MySQL - I stumbled upon this page which shows an overview of options available to me.
本頁底部的表格比較了與 mysql 通信的三種主要方法的功能.在API 支持客戶端準備好的語句"行中,它表示 PDO 支持這一點,而 MySQLi 不支持.
At the bottom of this page is a table comparing functionality of the three main methods of communicating with mysql. In the row "API supports client-side Prepared Statements", it says that PDO supports this and MySQLi doesn't.
我知道準備好的語句是什么.這個問題的答案是我認為服務器端準備好的語句的一個簡單示例.PHP 是一種服務器端語言,這反過來應該意味著客戶端準備好的語句是否可用并不重要.但這讓我想知道為什么當時甚至在 PHP 手冊中列出了這一點.
I know what prepared statements are. The answer to this question is a simple example of what I believe is server-side prepared statements. And PHP is a server-side language, which in turn should mean that it doesn't matter if client-side prepared statements are available or not. But that makes me wonder why that is even listed in the PHP manual then.
那么什么是客戶端準備好的語句?
So what are client-side prepared statements?
推薦答案
顯然,客戶端準備好的語句是由客戶端準備的語句,而不是服務器.
Obviously, client-side prepared statements are statements that are prepared by the client, rather than the server.
PDO 是一個數據訪問抽象層,支持多個 DBMS 接口(驅動程序),其中一些支持服務器端準備好的語句(例如:MySQL 4.1+),一些不支持(例如:MySQL 3).
PDO is a data-access abstraction layer that supports multiple DBMS interfaces (drivers), some of which support server-side prepared statements (e.g.: MySQL 4.1+), some of which don't (e.g.: MySQL 3).
如果 PDO 驅動程序不支持服務器端準備好的語句,PDO 將在客戶端模擬它們并使用通用查詢接口來執行它們.
In the event where the PDO driver does not support server-side prepared statements, PDO will emulate them on the client-side and use the generic query interface to execute them.
MySQLi 不支持它們的原因很簡單:MySQLi 是 MySQL 特定的擴展,一個確實支持服務器端準備好的語句的 RDBMS,因此沒有理由模仿它們.
The reason why MySQLi doesn't support them is simple: MySQLi is a MySQL-specific extension, a RDBMS that indeed supports server-side prepared statements, so there is no reason to emulate them.
這篇關于什么是客戶端準備好的語句?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!