-
Notifications
You must be signed in to change notification settings - Fork 1
Models
Models all share a common ancestry and a single Model class can only talk to one db connection as standard practice. However, there is a built-in mechanism to change what connection to use.
In order to use a db connection that is different from the one where the "webapp" is being used, create your inherited Model class and then change the const dbConnName = 'webapp'; to some other name, e.g. 'bob'. In your config folder (app/config/localhost for a localhost dev machine), copy the dbconn-webapp.ini file and name the copy as dbconn-bob.ini. Open that file up and change the credentials to what you need for the alternate db connection. Once you save the file, your model class will automatically connect using the credentials stored in dbconn-bob.ini and the Director class will automatically handle keeping track of the connection and sharing with any other Model class that may require it. Look in the app\DbConnInfo class for additional properties and methods you have access to via the Model::myDbConnInfo property.