An alternative way of doing this is to have separate 
database.php.<server> files, then (assuming linux/solaris/unix etc) 
create a database.php that softlinks to the correct file server 
depending on where you are.

This has an advantage if you ever want to point at the live database for 
whatever reason, you just change the softlink.

I have 3 sites running the same code in different geo's. The 
database.php (and bootstrap.php for that matter) point to their 
localised version. This enabled me to keep all the config separated per 
site, but still under good version control. (Automated) Deployment 
includes ensuring the softlink gets setup to the right machine file.

This probably is not as elegant as the solution below, which I really 
like, but might work for you if your circumstances fit.


On 11/20/08 04:49, [EMAIL PROTECTED] wrote:
> Nice–Thanks!
>
> On Nov 19, 11:07 pm, RyOnLife <[EMAIL PROTECTED]> wrote:
>   
>> Here's what I do:
>>
>> class DATABASE_CONFIG {
>>
>>         var $localhost = array(
>>                 'driver' => 'mysql',
>>                 'persistent' => false,
>>                 'host' => '127.0.0.1',
>>                 'login' => '',
>>                 'password' => '',
>>                 'database' => '',
>>                 'prefix' => '',
>>                 'encoding' => ''
>>         );
>>
>>   var $prod = array(
>>         'driver' => 'mysql',
>>         'persistent' => false,
>>         'host' => '',
>>         'login' => '',
>>         'password' => '',
>>         'database' => '',
>>         'prefix' => '',
>>         'encoding' => ''
>>   );
>>
>>   var $test = array(
>>         'driver' => 'mysql',
>>         'persistent' => false,
>>         'host' => '',
>>         'login' => '',
>>         'password' => '',
>>         'database' => '',
>>         'prefix' => '',
>>         'encoding' => ''
>>   );
>>
>>   var $default = array();
>>
>>   function __construct() {
>>     if([EMAIL PROTECTED]'SERVER_ADDR'] || @$_SERVER['SERVER_ADDR'] ==
>> '127.0.0.1'):
>>       $this->default = $this->localhost;
>>     else:
>>       $this->default = $this->prod;
>>     endif;
>>   }
>>
>>   function DATABASE_CONFIG() {
>>     $this->__construct();
>>   }
>>
>>
>>
>> }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to