How to write Php / MySQL command that tells wait for answer from MySQL for 5 sec only


Can one and if yes how can one write a Php MySQL command that tells Php

SELECT this command from MySQL
but if it takes more than 5 Seconds to get an answer from MySQL regarding this
SELECT then stop waiting for it and instead return 0 (or X) and go on to the
next command.


no, i don’t think so, no

Are you sure that the answer is NO!
I had read a few places online that there is a way to do this, but they were just not clear.


Your question is far too general and would be better if you could give more details of your search.

If you are looking to search for a phrase then a method I have used:

  1. split the phrase into a SEARCH array

  2. loop through the search array and seek each word

  3. if found then add to a FOUND array

  4. repeat until endof SEARCH array

  5. display results of FOUND array


Thanks for your suggestions.
But the issue is not that simple.
And really only away around it is if Php MySQL had a command which would allow for a certain
amount of time of a wait for an answer to come back and if none has come back in that X time
then for that SELECT to abort and move on to the next command (line), rather than hang the
whole program when a given server does not respond to a SELECT command.

i think he must have been trying to reply to some other thread :slight_smile:

Actually I was not replying to another thread and still maintain that a query should be simplified and the results used to create a more complex query.

I would still like to know further details of the failed query that requires aborting after 5 seconds.