笑故挽风 2012-10-12 13:18 采纳率: 100%
浏览 469
已采纳

为什么我不应该在 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条回答 默认 最新

  • Didn"t forge 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条)

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题