Greetings,
I posted this question on PHP Developer's Network - http://forums.devnetwork.net/viewtopic.php?t=42850 , but no one has come up with any suggestions so I hope it is ok to try this forum with the same question.
I have a PHP script that connects to an Ingres database, runs a query (or queries) and then connects to a MySQL database and runs a subsequent query or queries.
Occasionally, owing to queries that other users are running on Ingres and MySQL, the tables that I'm trying to query are locked. Consequently, the script just hangs until the tables are unlocked.
set_time_limit() cannot be used as the PHP manual states:
[FONT=Courier New]The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.[/FONT]
For Ingres, I've tried issuing the following SET prior to running the queries:
$link = ingres_connect($dbname, $user, $pass) or die("Could not connect");
$sql = "set lockmode session where readlock = nolock, timeout = 1";
ingres_query($sql) or die('problem setting timeout');
The SET seems to be issued without error, but the timeout never seems to fire, even when the tables are locked
Can anyone suggest a way in which I can force the Ingres and MySQL queries to timeout if they take longer than a specified time to execute?
Thanks