local-host 2012-10-12 13:18 采纳率: 100%
浏览 602
已采纳

为什么我不应该在 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

  • 写回答

13条回答 默认 最新

  • hurriedly% 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.

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

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记