Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

php - 为什么我不应该在PHP中使用mysql_ *函数?(Why shouldn't I use mysql_* functions in PHP?)

What are the technical reasons for why one shouldn't use mysql_* functions?

(为什么不应该使用mysql_*函数的技术原因是什么?)

(eg mysql_query() , mysql_connect() or mysql_real_escape_string() )?

((例如mysql_query()mysql_connect()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

(警告:mysql_connect():没有这样的文件或目录)

  ask by Madara Uchiha translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The MySQL extension:

(MySQL扩展:)

  • Is not under active development

    (没有积极发展)

  • Is officially deprecated as of PHP 5.5 (released June 2013).

    (从PHP 5.5(2013年6月发布)开始正式弃用 。)

  • Has been removed entirely as of PHP 7.0 (released December 2015)

    (自PHP 7.0(2015年12月发布)起完全删除。)

    • This means that as of 31 Dec 2018 it does not exist in any supported version of PHP.

      (这意味着截至2018年12月31日 ,任何受支持的PHP版本中都不存在该文件。)

      If you are using a version of PHP which supports it, you are using a version which doesn't get security problems fixed.

      (如果使用的PHP版本支持该版本,则使用的版本不会解决安全问题。)

  • Lacks an OO interface

    (缺乏OO接口)

  • 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)

      (“新”密码身份验证方法(MySQL 5.6中默认为启用; 5.7中为必需))

    • Any of the new functionality in MySQL 5.1 or later

      (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 .

(请参见SQL扩展的比较 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...