Why did you have to comment the disconnect? Did you take out the exit
statement when reporting the error? If so then close the DB connection if it
was successfully opened:
if ($conected)
{
$DataSource->disconnect();
}
This is to keep things clean.
I'm glad it worked for you Brad.
-MI
---------------------------------------------------------------------------
Remember, smart coders answer ten questions for every question they ask.
So be smart, be cool, and share your knowledge.
BAKE ON!
-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de Brad Daily
Enviado el: Jueves, 30 de Noviembre de 2006 01:48 a.m.
Para: Cake PHP
Asunto: Re: Catching DB connection failure
Thanks Mariano, that did the trick. One change I had to make was
commenting out this line in the else statement:
> $DataSource->disconnect();
Mariano Iglesias wrote:
> Edit your webroot/index.php file and look for the following lines:
>
> $Dispatcher=new Dispatcher();
> $Dispatcher->dispatch($url);
>
> Just before these two lines try adding the following code:
>
> $ConnectionManager =& ConnectionManager::getInstance();
> $DataSource = @$ConnectionManager->getDataSource('default');
>
> $connected = @$DataSource->connect();
>
> if (!$connected)
> {
> echo '<strong>COULD NOT CONNECT to database.</strong><br /><br />';
> echo 'Current Settings:';
> echo '<ul>';
> echo '<li>HOST: ' . $DataSource->config['host'] . '</li>';
> echo '<li>USER: ' . $DataSource->config['login'] . '</li>';
> echo '<li>DATABASE: ' . $DataSource->config['database'] . '</li>';
> echo '</ul>';
>
> exit;
> }
> else
> {
> $DataSource->disconnect();
> }
__________ Información de NOD32, revisión 1890 (20061129) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---