BKeeney ActiveRecord in a Web Project?

I’m wondering which is the right way to use the classes generated with ARGen in a Web project. ARGen is a very productive way to manage the database access, but it seems to me that is not possible to use it directly in a Web Project:

We know that inside a WebApp we have to open/close a database within a users Session, but the ARGen’s classes use a variable named ‘gDB’ as a reference to the db, but ‘gDB’ is a Module propriety, i.e. it is global to the App and not local to the user Session, and this can mismatch the things when there are simultaneous users.
Since the reference to gDB is pervasive trough all the classes, it is not practical to manually rename it to something like ‘Session.gDB’, as it would require to rename every ‘gDB’ instance in every Class each time ARGen is run to update the classes after some changes to the database structure.
For the same reason I think that is not possible to have two or more different database opened at the same time, as the propriety ‘gDB’ would be overwritten by Registering the second db.

So my question is: is it possible to actually use ARGen (and how) when writing a WebApp which will have multiple database and simultaneous users, or it is just not suited ?

Yes, it’s possible. Each database you are connecting to will need a connection in the App and Session. Then in your NameSpace modules (where all of the database work is done) you’ll need to have generic connection method for that database that can switch choose the proper connection.

So you might have a NameSpace called data and a method called DB that returns the database object. We’ve extended it even further so that if the connection is being used in a thread it will create a separate connection for the thread.

This will be added in a future update to ARGen. If you want an example, please email us at support@bkeeney.com