MySQL,MySQLi和PDO有什么区别? [英] What is the difference between MySQL, MySQLi and PDO?

查看:113
本文介绍了MySQL,MySQLi和PDO有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL, MySQLi 哪个是最适合与PHP-MySQL一起使用的?

Which one is the best suited to use with PHP-MySQL?

推荐答案

有三种(以上)从PHP使用MySQL的流行方法.本文概述了一些功能/差异 PHP:选择API :

There are (more than) three popular ways to use MySQL from PHP. This outlines some features/differences PHP: Choosing an API:

  1. (已弃用) mysql函数是程序性操作,请使用手动转义.
  2. MySQLi 替换了mysql函数,对象是面向和程序版本.它支持准备好的语句.
  3. PDO (PHP数据对象)是具有支持的常规数据库抽象层适用于MySQL和其他许多数据库.它提供了准备好的语句,并且在如何返回数据方面具有显着的灵活性.
  1. (DEPRECATED) The mysql functions are procedural and use manual escaping.
  2. MySQLi is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements.
  3. PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL among many other databases. It provides prepared statements, and significant flexibility in how data is returned.

我建议对准备好的语句使用PDO.它是一种经过精心设计的API,可让您更轻松地移至另一个数据库(包括支持 ODBC的数据库)(如有必要).

I would recommend using PDO with prepared statements. It is a well-designed API and will let you more easily move to another database (including any that supports ODBC) if necessary.

这篇关于MySQL,MySQLi和PDO有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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