How does ThinkPHP5 control how to connect to different databases?

demand: for Testin platform, testers to test, but does not affect the production environment of the database, you need to use a test list background, if the merchant number or logo exists on the list, connect to another test server database.

current situation: IOS, Android and H5 call the relevant APIs, while the APIs connect to different projects and databases. If there is any way, try to switch database connections between these three ends without much modification?

solution: when IOS, Android and the frontend call the API, header is globally set with the version number information to identify the specified agent and version number, and provide the backend to identify and determine whether to connect to the test server database.

Mar.04,2022

if you connect to different databases when requesting ios or android,h5, judge according to userAgent, and then get different database configurations


Hello, have you solved this problem? I'm also looking for answers.

Menu