Sunday, October 30, 2011

How to use and connect alternative database config when it's failed to connect to DB?

Hi all,
My Question is How to use and connect alternative database config when
it's failed to connect to DB?

Based on my question above, just give you the idea that on traditional
php programming, we can do like this :

$db_configs=array(

0=>array('host'=>'localhost1','user'=>'root1','password'=>'password1'),

1=>array('host'=>'localhost2','user'=>'root2','password2'=>'password2')
);

foreach($db_configs as $db_config)
{
if(!mysql_connect($db_config['host'],$db_config['user'],
$db_config['password'])
{
// DB Connection Failed, do nothing and try next db config...
}
else
{
echo 'DB Connection Success, Break';
break;
}
}

So the idea is, the script try to reconnect to database when it's
failed and using alternative config variable.

How can we do like that on CakePHP ?

Thank you.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: