I'm working on a PHP/MySQL project that requires accessing multiple databases. Previously, when I only needed to access one database, I had defined constants for the database server, username, password and name (DB_SERVER, DB_USER, ect...). However now that my application is accessing multiple databases, I cannot simply define this information using constants anymore.
I have a database class which handles opening and closing the connection each time a script is run; mysql_connect(DB_SERVER, DB_USER, DB_PASS) and mysql_select_db functions are called from within this class.
Based on which database the application needs to connect to, is it safe to use super global variables to set the appropriate connection information? Should I pass the connection information as arguments to my database class? Or should I rethink this entirely?
Suggestions or advice would be appreciated!