客户端准备好的语句是什么? [英] What are client-side prepared statements?

查看:75
本文介绍了客户端准备好的语句是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试学习新知识-专门尝试选择是否使用 MySQLi

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.

这篇关于客户端准备好的语句是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆