How To Work With Multiple Connection Objects
When working with a SQL Yoga Database object you can create any number of Connection objects by calling dbconn_createObject. This lesson will show you how you can work with multiple Connection objects in your code.
In order to make writing SQL Yoga code easier, all API calls in the library assume you are targeting the default Connection Object of the default Database object. The name of the default Connection object is a property of a Database object and can be retrieved by calling dbobject_get():
put dbobject_get("default connection")
For example, you look at the sqlquery_createObject function you will notice a 2nd and 3rd parameters are optional: pConnection and pDBKey. If the 4th parameter is empty then the Database object name returned by sqlyoga_getDefaultDatabase() will be used. If the 3rd parameter is empty then the default Connection object of the Database object will be used.
If you want to work with more than one Connection Object you have two options.
The first option is to pass in the name of the Connection object to any API calls that accept the pConnection parameter.
put sqlquery_createObject("lessons", "my connection name") into theQueryA
The second option is to change the name of the default Connection object by setting the "default connection" property for the Database Object using dbobject_set:
dbobject_set "default connection", "my connection name"