零零乙 2012-10-12 13:18 采纳率: 33.3%
浏览 704
已采纳

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

What are the technical reasons for why one shouldn't use mysql_* functions? (e.g. mysql_query(), mysql_connect() or mysql_real_escape_string())?

Why should I use something else even if they work on my site?

If they don't work on my site, why do I get errors like

Warning: mysql_connect(): No such file or directory

转载于:https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php

  • 写回答

14条回答 默认 最新

  • Lotus@ 2012-10-27 15:20
    关注

    The MySQL extension:

    • 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 will not exist in any supported version of PHP. Currently, it only gets security updates.
    • Lacks an OO interface
    • Doesn't support:
      • Non-blocking, asynchronous queries
      • Prepared statements or parameterized queries
      • Stored procedures
      • Multiple Statements
      • Transactions
      • The "new" password authentication method (on by default in MySQL 5.6; required in 5.7)
      • All of the functionality in 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.

    See the comparison of SQL extensions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(13条)

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划