There is a property which is part of model called $useDbConfig.
>From a controller you can call or set it like:
$this->model->setSource('mydbConfig');
To get the current model dbConfig call
currentconfig = $this->model->getDataSource();

If your storing your config info in database1. you would build up your
default config to point at this database.
in your appcontroller or your appmodel you make use of your dbconfig
model and query for the specific model.

I suppose your dbconfig schema would have fields that match up to the
database.php config array
array(
'driver' => 'mysql',
'persistent' => false,
'host' => SANDBOX_DB_HOST,
'port' => '',
'login' => SANDBOX_DB_USERNAME,
'password' => SANDBOX_DB_PASSWORD,
'database' => SANDBOX_DB_NAME,
'schema' => '',
'prefix' => '',
'encoding' => ''
);
With some additional fields based on how you want to find the
dbconfig. Based on your request I'd say at least Model.
your query would do a findbymodel to retreive the info.
You would then need to replace the assigned var $customdb in the
DATABASE_CONFIG class.
once you've done that you can set or assign the configuration to each
model.

One question what is the reason for storing the connection info in a
database?
if you only have a few connections you could easily add multiple
config arrays to the database_config in app\config\database.php and
just switch them out using the $this->model->setSource
('config_var_name');

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

Reply via email to