This is for Kohana v3.2
How can I dynamically choose the database an ORM model connects to? Specifically, I am trying to change an ORM model to work with databases in my local dev, staging and production environments.
The Kohana Guide tells me I can set the database connection by setting a protected property on the ORM model like this:
class Model_Customer extends ORM
{
protected $_db_group = 'local_db';
protected $_table_name = 'customer';
This works fine when developing locally, but what about when I move to stage and then production? I'd rather not have to change the _db_group each time I change environments. I can check server vars to determine environment, but I haven't been able to figure out a way to dynamically set the db_group property to match the environment since I can't do any logic in a class definition.
There's probably a better way to approach this problem that I'm hoping someone will be able to suggest. Thanks.