[eluser]elverion[/eluser]
So, I need two use two databases in one of my projects. No big problem there, as that is covered in the user guide. The problem, however, is that I'm not sure how to best go about loading those databases to prevent a number of issues.
First, both databases should be accessible from all models. Using global variables to store the handles works, but then you run into the problem that now your models aren't reusable without changing the variable names when you want to use it in a new project. Globals are just kind of a bad option, but they "work."
Now, I could also load the databases in each function in a model or within the model constructor. It is better for reusability, but you might be making multiple function calls to models or even using multiple models per page, so wouldn't it create multiple handles per database (seeing as how persistent connections don't work well with multiple databases)? I could see this causing issues with many page accesses at the same time.
So, how would you avoid globals (or similar methods) without potentially re-loading databases when it isn't necessary?