Hi All,

I think it would be worth your time to investigate using an AppError
class. In this way there's no hacks, you can just override what happens
when there is no connection or no table etc. To check the existance of
all resources - just include all of them in a controller, if all
tables, helpers, components etc. exist - there will be no error,
otherwise the appError <relavent method> is triggered. So the code in
the "check everything's present" controller, which has all models
components and helpers inlcuded, the index method would just be
{redirect->(/);}.

I recently updated most of the downloadable plugins on my site to
handle missing connections tables, and 3rd party code to display an
error message of my choice from within the plugin. In the case of
missing tables, the needed SQL is displayed, to extend this to allow
the user to run the SQL wouldn't be difficult. Still WIP, but if you
want something to go with have a look at the code for any of the demos
(except the blog, as that's next on the list).

HTH,

AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no
results for the google group.
The wiki may contain incorrect info - read at your own risk (it's
mainly user submitted) :)
You may get your answer quicker by asking on the IRC Channel (you can
access it with just a browser here: http://irc.cakephp.org).

On Nov 30, 8:01 am, "Mariano Iglesias" <[EMAIL PROTECTED]>
wrote:
> 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 systemhttp://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to