Re: dynamic connection according environment

2007-06-05 Thread francky06l
I found a solution to this, maybe it's not elegant and has some drawbacks. into the index.php of webroot I declared : define('DBSPOT', 'dev.mydb'); into the database.php just replace 'database' => DBSPOT, It works wihtout problems, this solution works if you use the same user/pw and also t

Re: dynamic connection according environment

2007-06-05 Thread AD7six
On Jun 5, 9:45 am, MrTufty <[EMAIL PROTECTED]> wrote: > The easiest technique I've seen used an additional to the database.php > in app/config, which sets the DB config based on the host. I concur :). If you do the switching in your app model - that might be too late. Before any app code is ru

Re: dynamic connection according environment

2007-06-05 Thread MrTufty
The easiest technique I've seen used an additional to the database.php in app/config, which sets the DB config based on the host. There's some code floating around somewhere, but I can't remember where the link was at the moment. Perhaps someone else knows what I'm talking about! On Jun 5, 3:34 a

Re: dynamic connection according environment

2007-06-04 Thread LePetitNicolas
Hi, I would use the AppModel as mentioned before. A simple approach (in Cake 1.1.x.x) : Define a constant in your app/bootstrap.php file //... define('DEV_HTTP_HOST', 'example.dev'); //... and then set $useDbConfig in your AppModel function __construct() { //... if ($_SERVER['HTTP_HOST'] ==

Re: dynamic connection according environment

2007-06-04 Thread Geoff Ford
Whats wrong with putting it in app_model.php. I think that this is the easiest and logical approach. If you really want it in the controller what about AppController::beforeFilter() (http://api.cakephp.org/ class_controller.html#e756a803e378b692480ba0ab107c9bee). However you would have to set it

dynamic connection according environment

2007-06-04 Thread PiLLo
Hi, following the MVC ideology, does anybody know how to change the connection according to the environment where we publish an application? For example, in a development enviroment I have http://Tequila and on the models I declare $useDbConfig="development_connection"; So the problem begins when