Closed back-2-95 closed 12 years ago
There is already a way to accomplish this, but it's not in the docs.
If you set an attribute called database in your config file, along where you usually specify host, username etc then that will be the database used so long as there is no static::$_db variable set on models.
I've been meaning to document this but I'm waiting until i finish a related feature.
Can you provide quick example? I use application.ini file to set my Zend_Application.
Checkout https://github.com/coen-hyde/Shanty-Mongo/wiki/Connections
You could have something like this in your .ini file:
mongo.host = 'mongohost.local' mongo.database = 'my_database'
Then do something like: Shanty_Mongo::addConnections($config->mongo)
Then remove the static::$_db setting in your models.
Thanks! I appreciate this! =)
Hi,
Could there be public set method for defining protected static $_db ? Llike setDb($db) ?
I would like to store db name in my config and set it once for all my document types. And of course with this method I could use other dbs also.
br, Marko