尝试学习新东西 - 特别是尝试选择使用 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模板网!