On Tue, Jan 29, 2013 at 1:29 PM, Lester Caine <les...@lsces.co.uk> wrote:
> Can someone please fill in a little information here. When we start > looking at multiple threads doing for example database lookups in parallel > with the main page generation. Does that involve 'thread safe' or is it > done in a different way? Scheduling a data lookup on one thread while > building the page the information is to be displayed on seems like a case > for threading in the web server? > > we don't have threads in userspace in php, sou you can't do concurrent execution of any function, but there are a couple of extensions providing some way for concurrent/async execution. for the scenario what you described one can use multiple db connections and async queries http://www.php.net/manual/en/mysqli.poll.php#refsect1-mysqli.poll-examplesfor mysql or just a single connection and doing some other work (like rendering the layout) while waiting for the results. if you are interested in a generic solution for concurrent execution you could look into http://php.net/manual/en/book.pthreads.php -- Ferenc Kovács @Tyr43l - http://tyrael.hu