database failure so code reverts to flat file?

This is a discussion on database failure so code reverts to flat file? within the PHP Language forums, part of the PHP Programming Forums category; Is there a way to tell PHP, "Spend 5 seconds trying to reach the database, if you can't ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-18-2004
lawrence
 
Posts: n/a
Default database failure so code reverts to flat file?

Is there a way to tell PHP, "Spend 5 seconds trying to reach the
database, if you can't reach it, then load the file from the cached
flat file."

I suspect the answer is no. I'm tempted to rewrite all my code in
Java, just so I can have threads. And private methods. And private
class properties. And real encapsulation. And interfaces. And abstract
classes. And the ability to do anything.
Reply With Quote
  #2 (permalink)  
Old 06-19-2004
Gordon Burditt
 
Posts: n/a
Default Re: database failure so code reverts to flat file?

>Is there a way to tell PHP, "Spend 5 seconds trying to reach the
>database, if you can't reach it, then load the file from the cached
>flat file."


mysql.connect_timeout can be set to make a connection time out if
it's taking too long. Unfortunately it seems to be settable only
on a system-wide basis.

PHP does not cache flat files unless you tell it to do so and how
to do so. However you managed that, you could tell PHP to do it
if the connection attempt timed out.

Gordon L. Burditt
Reply With Quote
  #3 (permalink)  
Old 06-19-2004
CJ Llewellyn
 
Posts: n/a
Default Re: database failure so code reverts to flat file?

"lawrence" <lkrubner@geocities.com> wrote in message
news:da7e68e8.0406181203.2440cf9b@posting.google.c om...
> Is there a way to tell PHP, "Spend 5 seconds trying to reach the
> database, if you can't reach it, then load the file from the cached
> flat file."
>
> I suspect the answer is no. I'm tempted to rewrite all my code in
> Java, just so I can have threads. And private methods. And private
> class properties. And real encapsulation. And interfaces. And abstract
> classes. And the ability to do anything.


Use ticks (or Java)

http://uk2.php.net/manual/en/functio...k-function.php



Reply With Quote
  #4 (permalink)  
Old 06-28-2004
lawrence
 
Posts: n/a
Default Re: database failure so code reverts to flat file?

"CJ Llewellyn" <satest@tmslifeline.com> wrote in message news:<cavsvd$2iv$1@slavica.ukpost.com>...
> "lawrence" <lkrubner@geocities.com> wrote in message
> news:da7e68e8.0406181203.2440cf9b@posting.google.c om...
> > Is there a way to tell PHP, "Spend 5 seconds trying to reach the
> > database, if you can't reach it, then load the file from the cached
> > flat file."
> >
> > I suspect the answer is no. I'm tempted to rewrite all my code in
> > Java, just so I can have threads. And private methods. And private
> > class properties. And real encapsulation. And interfaces. And abstract
> > classes. And the ability to do anything.

>
> Use ticks (or Java)
>
> http://uk2.php.net/manual/en/functio...k-function.php


That's a good function that I didn't know about. It looks just like
timer() in javascript. Still, it is not threads, as near as I
understand it. What would I call to stop a database call and switch
directions isn't clear to me. Perhaps a function that tests the if the
database connection was already made, and if not, then get the flat
file?
Reply With Quote
  #5 (permalink)  
Old 06-28-2004
lawrence
 
Posts: n/a
Default Re: database failure so code reverts to flat file?

gordonb.mgon3@burditt.org (Gordon Burditt) wrote in message news:<cavr4p$5lf@library2.airnews.net>...
> >Is there a way to tell PHP, "Spend 5 seconds trying to reach the
> >database, if you can't reach it, then load the file from the cached
> >flat file."

>
> mysql.connect_timeout can be set to make a connection time out if
> it's taking too long. Unfortunately it seems to be settable only
> on a system-wide basis.
>
> PHP does not cache flat files unless you tell it to do so and how
> to do so. However you managed that, you could tell PHP to do it
> if the connection attempt timed out.


I'll give that a try, thanks.
Reply With Quote
  #6 (permalink)  
Old 06-28-2004
CJ Llewellyn
 
Posts: n/a
Default Re: database failure so code reverts to flat file?

"lawrence" <lkrubner@geocities.com> wrote in message
news:da7e68e8.0406271446.50567d07@posting.google.c om...
> "CJ Llewellyn" <satest@tmslifeline.com> wrote in message

news:<cavsvd$2iv$1@slavica.ukpost.com>...
> > "lawrence" <lkrubner@geocities.com> wrote in message
> > news:da7e68e8.0406181203.2440cf9b@posting.google.c om...
> > > Is there a way to tell PHP, "Spend 5 seconds trying to reach the
> > > database, if you can't reach it, then load the file from the cached
> > > flat file."
> > >
> > > I suspect the answer is no. I'm tempted to rewrite all my code in
> > > Java, just so I can have threads. And private methods. And private
> > > class properties. And real encapsulation. And interfaces. And abstract
> > > classes. And the ability to do anything.

> >
> > Use ticks (or Java)
> >
> > http://uk2.php.net/manual/en/functio...k-function.php

>
> That's a good function that I didn't know about. It looks just like
> timer() in javascript. Still, it is not threads, as near as I
> understand it. What would I call to stop a database call and switch
> directions isn't clear to me. Perhaps a function that tests the if the
> database connection was already made, and if not, then get the flat
> file?


It's not threading, the best I could describe it would be the same as adding
a call back function to the main php interpreter execution loop.

Your function should check to call to see if it had been called before, if
not attempt a sql connection. If it has, check to see if the connection is
timed out then cancel the tick function and exit the waiting loop.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0