問(wèn)題描述
嘗試學(xué)習(xí)新東西 - 特別是嘗試選擇使用 MySQLi 還是 PDO 用于將來(lái)使用 MySQL 的項(xiàng)目 - 我偶然發(fā)現(xiàn)了 這個(gè)頁(yè)面 顯示了我可用的選項(xiàng)概覽.
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.
本頁(yè)底部的表格比較了與 mysql 通信的三種主要方法的功能.在API 支持客戶(hù)端準(zhǔn)備好的語(yǔ)句"行中,它表示 PDO 支持這一點(diǎn),而 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.
我知道準(zhǔn)備好的語(yǔ)句是什么.這個(gè)問(wèn)題的答案是我認(rèn)為服務(wù)器端準(zhǔn)備好的語(yǔ)句的一個(gè)簡(jiǎn)單示例.PHP 是一種服務(wù)器端語(yǔ)言,這反過(guò)來(lái)應(yīng)該意味著客戶(hù)端準(zhǔn)備好的語(yǔ)句是否可用并不重要.但這讓我想知道為什么當(dāng)時(shí)甚至在 PHP 手冊(cè)中列出了這一點(diǎn).
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.
那么什么是客戶(hù)端準(zhǔn)備好的語(yǔ)句?
So what are client-side prepared statements?
推薦答案
顯然,客戶(hù)端準(zhǔn)備好的語(yǔ)句是由客戶(hù)端準(zhǔn)備的語(yǔ)句,而不是服務(wù)器.
Obviously, client-side prepared statements are statements that are prepared by the client, rather than the server.
PDO 是一個(gè)數(shù)據(jù)訪問(wèn)抽象層,支持多個(gè) DBMS 接口(驅(qū)動(dòng)程序),其中一些支持服務(wù)器端準(zhǔn)備好的語(yǔ)句(例如: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 驅(qū)動(dòng)程序不支持服務(wù)器端準(zhǔn)備好的語(yǔ)句,PDO 將在客戶(hù)端模擬它們并使用通用查詢(xún)接口來(lái)執(zhí)行它們.
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 不支持它們的原因很簡(jiǎn)單:MySQLi 是 MySQL 特定的擴(kuò)展,一個(gè)確實(shí)支持服務(wù)器端準(zhǔn)備好的語(yǔ)句的 RDBMS,因此沒(méi)有理由模仿它們.
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.
這篇關(guān)于什么是客戶(hù)端準(zhǔn)備好的語(yǔ)句?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!