How To Work With Multiple Database Objects
When working with SQL Yoga you can create any number of Database objects by calling dbobject_createObject. This lesson will show you how you can work with multiple Database 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 Database object. The name of the default Database object is the value returned from sqlyoga_getDefaultDatabase().
For example, if you look at the dbconn_createObject command you will notice a 4th parameter that is optional: pDBKey. If this parameter is empty then the Database object name returned by sqlyoga_getDefaultDatabase() will be used.
If you want to work with more than one Database Object you have two options.
1) Pass in the name of the Database object to any API calls that accept the pDBKey parameter.
dbconn_createObject "my connection", "sqlite",, "my database object name"
2) Change the name of the default Database object by calling sqlyoga_setDefaultDatabase.
sqlyoga_setDefaultDatabase "my database object name"