热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

我可以同时包含MySQL和MySQLi数据库连接文件吗?-CanIincludingbothMySQLandMySQLidatabaseconnectionfiles?

Heyhavecodedallmysitewithmysqli.ButmostofthescriptsIfoundfromGitHuborothersuchsi

Hey have coded all my site with mysqli. But most of the scripts I found from GitHub or other such sites are coded with mysql.

嘿我用mysqli编写了我的所有网站。但是我从GitHub或其他类似网站发现的大多数脚本都是用mysql编写的。

So, when am implementing that in my projects should i replace the mysql with mysqli or can i use both of them in my connection files and all other PHP files??

那么,当我在我的项目中实现时,我应该用mysqli替换mysql还是我可以在我的连接文件和所有其他PHP文件中使用它们?

2 个解决方案

#1


There is nothing stopping you from using both, but were I you I would choose one type of connection and go along with it. Mixing can be confusing not only for other people who read your code but also your future self.

没有什么可以阻止你使用它们,但我是你,我会选择一种类型的连接,并与它一起使用。混音不仅会让其他阅读代码的人感到困惑,也会混淆你未来的自我。

#2


You can use both of them. However this does not mean you should. You should not use 2 connections. For multiple reasons:

您可以同时使用它们。但这并不意味着你应该这样做。你不应该使用2个连接。出于多种原因:

  • Mysql is deprecated as of PHP 5.5.0, and will be removed in the future..
  • 从PHP 5.5.0开始,不推荐使用Mysql,将来会删除它。

  • Multiple database connections and more files which means performance issues.
  • 多个数据库连接和更多文件,这意味着性能问题。

  • It's very confusing to work with 2 different connections while it's not needed at all.
  • 使用2个不同的连接时非常困惑,而根本不需要它。


推荐阅读
author-avatar
郭辛奇木书可卿
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有