Tuesday, July 16, 2013

RE: Dynamic Databse selection

Thanks!

 

Took 5 mins to setup and exactly what I was looking for the different environments.

 

Dave

 

From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf Of euromark
Sent: Tuesday, July 16, 2013 9:35 AM
To: cake-php@googlegroups.com
Subject: Re: Dynamic Databse selection

 

I have always used http://www.dereuromark.de/2012/02/25/dynamic-database-switching/ (since 1.3).

It switches based on domain (or path in cli).

 


Am Dienstag, 16. Juli 2013 13:37:24 UTC+2 schrieb advantage+:

Is there a simply way to switch database based on it being local or on actual domain server.

 

Example:

 

<?php

class DATABASE_CONFIG {

 

                public $local = array(

                                'datasource' => 'Database/Mysql',

                                'persistent' => false,

                                'host' => 'localhost',

                                'login' => 'local',

                                'password' => '******',

                                'database' => 'local_db',

                                'encoding' => 'utf8'

                );

               

               

                public $remote = array(

                                'datasource' => 'Database/Mysql',

                                'persistent' => false,

                                'host' => 'localhost',

                                'login' => 'remote',

                                'password' => '******',

                                'database' => 'remote_db',

                                'encoding' => 'utf8'

                );

}

 

Rather than having to switch between to 2 configurations when making changes local for testing then switch and upload to remote, then switch back to local to continue making edits.

So if local will use $local config, or on actual server use $remote config.

 

Thanks guys.

Dave

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: