473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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.
Jul 17 '05 #1
5 1775
>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
"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
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jane Doe | last post by:
Hi, Besides Pivot (I'd rather wait for the final release), EasyCMS (the navigation bar is static), and CMSimple (all documents saved in a single HTML, so not good for lengthy articles)... do you...
12
by: siliconmike | last post by:
How do I synchronize MySQL table data of my home PC with latest data from a remote server ? My home PC is on a very slow internet connection, so implementing replication will cause long time...
5
by: Paul M. | last post by:
Hi, Are there any examples of building a simple local database with C# Express 2005? TIA
14
by: vunet.us | last post by:
Hi, I would like to use flat file data storage instead of database. Since I am new to it, I am wondering: What text file extension is a safe one to store my data online and how cost- and...
5
by: jacques.steward | last post by:
I have an application that kicks off a long process on the database server with a separate thread and then forwards the user to another page which monitors the progress of this process by reading a...
10
by: ircmaxell | last post by:
Ok, I have a program that reads the contents of a file (1 line, 5 '|' seperated items). Every so often (between twice a day, and 200 times a day), it rewrites the contents of that file. I also do...
1
by: Fordraiders | last post by:
vb.net 2003 Office 2003 What I have: C:\TestData\Input.txt Text File Pipe Delimited : 4 columns Of data example: 00001|NO BRAND NAME ASSIGNED|6DU27|M3-.5 X 6 FLAT HD SOCKET CAP SCREW,...
5
by: felciano | last post by:
Hello -- Is there a convention, library or Pythonic idiom for performing lightweight relational operations on flatfiles? I frequently find myself writing code to do simple SQL-like operations...
3
by: Flugeldorph | last post by:
I am new to Visual Basic, my preferred languages is C or C++. I am trying to load a local database with data that I am reading from a delimited flat file. I have created the database tables and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.