@author : Johan Barbier <firstname.lastname@example.org>
@Version : 2006/10/09
Needed : PHP 5, short_open_tags to Off
This package is meant to retrieve a huge amount of data, or process a big php script, and not being annoyed by PHP time limit
(ie : set_time_limit, and max_execution_time).
Sometimes, you do not want, or can, modify this timeout. But it can be pretty annoying if you have a big file to read, or a huge query to process.
Well, this package can help you!
Basically, it uses xmlhttp requests to ask the server to process a part of the main process.
For exemple, for a file, it will read lines 0 to 10, then 11 to 20, and so on.
That way, you will never hit PHP time limit, but your 50000 lines file will be read and displayed anyway.
The file (or query results, or whatever) will be flushed step by step.
Just have a look at the indexX.php exemple pages.
In most of them, PHP time limit has been set to 2s.
Addition from the 20th of October 2006 : now, stacks are supported. You can declare several stacks and have them work asynchronously.
The package consists of 2 classes:
=> used to initialize the xmlhttp object and the required methods.
noTimeOut::initialize() method shows the properties that can/must be set
NOTA : the ARGS property is an array. It can be used to send other variables to the PHP script (useful for the new oneShot method : a basic Ajax one shot request)
noTimeOut::getData() method shows you the types of processes that can be used.
- instanciate your object :
var oBuffer = new noTimeOut ();
- declare a stack :
- initialize your properties :
oBuffer.initialize (Stack_Name, Prop_Name, Prop_Value);
- start it!
=> used to process the scripts.
noTimeOut::aProps shows all the properties that can/must be initialized (it depends on the type of process chosen).
noTimeOut::aTypes shows the possible types of process (up to now)
noTimeOut::aDbServers shows the sql servers supported up to now, in a DB type of process
noTimeOut::flushMe () is the method used to flush the process
In the scripts/ folder, you will find the scripts using this class.
Basically : initialize your properties, and use flushMe() to process.
Have a look at the indexX.php exemple pages to see how to use the classes, and the different types of processes.
If you want to use the index2.php you first have to create a 'tests' database, and use the test.sql file to insert the data.
PROPERTIES JS :
START : the starting point of the request
LIMIT : the ending point of the request
STEP : the step of the request
SUBSTR : how many characters must we substract from the xmlhttp response (4 = minus 4, but -4 = plus 4)
FILE : if the request is about a file, filename
QUERY : if the request is about a query, query string
TARGET : where to put the result
SCRIPT : PHP script processing the request
MSG : where to put states changes messages
MSG_WAITING : waiting message
MSG_LOADED : loaded message
MSG_READY : ready message
METHOD : request method (POST or GET)
TYPE : the type of request (see below)
ARGS : misc arguments to be given to the SCRIPT. Must be an array.
TIMEOUT : is there a JS timeout on this stack. Useful for a batch process mixed with some user's action, with the noTimeOut::oneShot() method
TYPES JS :
DEFAULT : the default type. can be used to read an array, for example.
FILE_OCTET : request on a file, based on octets
FILE_LINE : request on a file, but based on lines
FILE_PATTERN : request on a file, but based on a pattern matching
DB : request on a DB (readonly, right now)
ONE_SHOT : a one shot request. For example, a user's action updating something.