且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我不应该在 PHP 中使用 mysql_* 函数?

更新时间:2022-03-21 04:58:04

MySQL 扩展:

  • 未在积极开发中
  • 自 PHP 5.5(2013 年 6 月发布)起正式弃用).
  • 从 PHP 7.0 开始完全删除(2015 年 12 月发布)
    • 这意味着从 2018 年 12 月 31 日起,它在任何受支持的 PHP 版本中都不存在.如果您使用的 PHP 版本支持它,那么您使用的版本不会修复安全问题.
    • Is not under active development
    • Is officially deprecated as of PHP 5.5 (released June 2013).
    • Has been removed entirely as of PHP 7.0 (released December 2015)
      • This means that as of 31 Dec 2018 it does not exist in any supported version of PHP. If you are using a version of PHP which supports it, you are using a version which doesn't get security problems fixed.
      • 非阻塞、异步查询
      • 准备好的语句或参数化查询强>
      • 存储过程
      • 多条语句
      • 交易
      • 新"密码身份验证方法(在 MySQL 5.6 中默认启用;在 5.7 中需要)
      • MySQL 5.1 或更高版本中的任何新功能

      由于它已被弃用,因此使用它会使您的代码缺乏未来证明.

      Since it is deprecated, using it makes your code less future proof.

      缺乏对准备好的语句的支持尤其重要,因为与使用单独的函数调用手动转义外部数据相比,它们提供了一种更清晰、更不容易出错的转义和引用外部数据的方法.

      Lack of support for prepared statements is particularly important as they provide a clearer, less error-prone method of escaping and quoting external data than manually escaping it with a separate function call.

      SQL扩展对比.