I'm running the same cake app on two different servers, development
and production. I want to change the database config that's used
depending on the server. I've got the following set up now.

/config/database.php

class DATABASE_CONFIG {
        var $development = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'localhost',
                'port' => '',
                'login' => 'admin',
                'password' => 'password',
                'database' => 'db',
                'schema' => '',
                'prefix' => '',
                'encoding' => ''
        );
        var $production = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'localhost',
                'port' => '',
                'login' => 'user_admin',
                'password' => 'password',
                'database' => 'user_db',
                'schema' => '',
                'prefix' => '',
                'encoding' => ''
        );
}

/models/table.php

class Table extends AppModel
{
        var $name = 'Table';

        function beforeFind()
        {
                if(is_dir('D:\webserver\private_html\site'))
                {
                        $this->useDbConfig = 'development';
                }
                elseif(is_dir(DS.'home'.DS.'user'.DS.'public_html'))
                {
                        $this->useDbConfig = 'production';
                }
        }
}

It just keeps trying to use the 'default' config. I've also tested my
logic by just putting $this->useDbConfig = 'development'; directly
under the beforeFind() function, but it still does nothing. Do I need
to put this somewhere else?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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