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

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

问题描述

MySQL、MySQLiPDO?

哪个最适合与 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天全站免登陆