在一个php项目的不同模块中使用2个MySQL数据库 [英] use 2 MySQL database in different module in one php project

查看:209
本文介绍了在一个php项目的不同模块中使用2个MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,
我需要准确的信息,我有一个包含多个模块的php项目,我需要访问不同的MySQL数据库.
像教育模块一样将被访问db_education数据库和
业务模块将被访问db_business数据库.是否有可能,如果是商业项目之类的大项目是否会成为问题.我该如何在需要想法的项目中实施.

任何帮助,谢谢.

马哈茂德

软件工程师

Dear,
I need a information accurately,I have a php project that have multiple module i need access different MySQL database.
like education module will be accessed db_education database and
business module will be accessed db_business database.Is it possible and if then can it be problem in big project like commercial project.how can i implement in project like need idea.

any help thanks in advance.

Mahmud

Software Engineer

推荐答案

是的,有可能.

最简单的方法是以具有访问两个数据库权限的用户身份连接到MySQL服务器,然后查询数据库名称限定的表:

Yes, it is possible.

The easiest way is to connect to the MySQL server as a user with permission to access both databases, then query the tables qualified by the database name:

SELECT name FROM db_business.contacts



如果必须使用单独的用户访问每个数据库,则可以使用多个连接.



If you must use separate users to access each database, you can use multiple connections.


这篇关于在一个php项目的不同模块中使用2个MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆