我什么时候应该使用 MySQLi 而不是 MySQL? [英] When should I use MySQLi instead of MySQL?
问题描述
有人可以为我澄清一下使用 MySQLi 而不是 MySQL 的优点和缺点吗?是否存在我不应该使用 MySQLi 的情况?我是否需要以不同的方式配置我的服务器才能使用 MySQLi?例如,我是否需要升级 Apache 或 PHP 才能支持 MySQLi?
Can someone clarify for me what the advantages and disadvantages of using MySQLi instead of MySQL? Are there situations where I should not use MySQLi? Do I need to configure my server differently in order to use MySQLi? For instance, do I need to upgrade Apache or PHP so I can support MySQLi?
推荐答案
你应该使用 MySQLi 扩展而不是 MySQL 扩展的原因有很多:
Reasons why you should use MySQLi extension instead of the MySQL extension are many:
- MySQLi 为您提供准备好的语句 - 一种将数据发送到 MySQL 并保护您免受 SQL 注入的更安全的方式.仅这一点就足以让您始终选择 MySQLi 而不是 MySQL.
- MySQLi 支持大部分 MySQL 功能.
- MySQLi 是面向对象的.
- MySQLi 支持准备好的语句、事务和多个语句.
- 旧的 MySQL 扩展是 自 PHP 5.5.0 起弃用莉>
还有其他好处.但主要是,您应该关注安全性和稳定性——而 MySQLi 正是如此.
And there are other benefits. But mainly, you should focus on security and stabiltity - and MySQLi gives you just that.
这篇关于我什么时候应该使用 MySQLi 而不是 MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!