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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
>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 |
|
|||
|
"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 |
|
|||
|
"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? |
|
|||
|
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. |
|
|||
|
"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. |