In the DATABASE_CONFIG class, I like to write a constructor that sets
$this->default to the correct DB connection settings based on
env('HTTP_HOST') or some such server- or environment- specific logic.
You declare your configuration alternates just as you would declare
the default configurations.  For example:

class DATABASE_CONFIG {

        var $default = null;

        var $dev = array(
                'driver' => 'sqlite',
                'persistent' => false,
                'database' => '/path/to/file.db'
        );

        var $live = array(
                'driver' => 'mysql',
                'persistent => true,
                'host' => 'localhost',
                'login' => 'user',
                'password' => '********',
                'database' => 'yourDb'
        );

        function __construct() {
                if (env('SERVER_NAME') == 'your-site.example.com')
{ // liver server
                        $this->default = $this->live;
                } else { // dev server
                        $this->default = $this->dev;
                }
        }
}

Hope that helps.

P.S. I can't remember where I saw this trick originally.  I'll provide
a link if I find it.

On Jul 21, 2:54 pm, flapjack <[EMAIL PROTECTED]> wrote:
> I ask this because I don't want to change code, but I do want to
> change databases, when I move code from a "dev" into "staging" server.
> If I have many entries in my DATABASE_CONFIG class, and I can read my
> environment using something like env('ORIG_PATH_TRANSLATED');
> Where is the best place to code a switch, to use a database to match
> the sub-domain?
>
> I appreciate the help,
--~--~---------~--~----~------------~-------~--~----~
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