By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,662 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

database failure so code reverts to flat file?

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
>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
Jul 17 '05 #2

P: n/a
"lawrence" <lk******@geocities.com> wrote in message
news:da**************************@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

Jul 17 '05 #3

P: n/a
"CJ Llewellyn" <sa****@tmslifeline.com> wrote in message news:<ca**********@slavica.ukpost.com>...
"lawrence" <lk******@geocities.com> wrote in message
news:da**************************@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?
Jul 17 '05 #4

P: n/a
go***********@burditt.org (Gordon Burditt) wrote in message news:<ca********@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.
Jul 17 '05 #5

P: n/a
"lawrence" <lk******@geocities.com> wrote in message
news:da**************************@posting.google.c om...
"CJ Llewellyn" <sa****@tmslifeline.com> wrote in message

news:<ca**********@slavica.ukpost.com>...
"lawrence" <lk******@geocities.com> wrote in message
news:da**************************@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.

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.