如何管理PHP odbc_exec超时? [英] How to manage PHP odbc_exec timeout?
问题描述
我有一个命令行PHP脚本,该脚本使用ODBC连接连接到SQL Server 2005.它使用odbc_exec()执行存储过程,该过程可能需要一段时间才能处理,而且我不希望它超时.
I've got a command-line PHP script that connects to SQL Server 2005 using an ODBC connection. It uses odbc_exec() to execute a stored procedure which may take a while to process, and I don't want it to timeout.
我一直无法在PHP文档中找到有关如何设置odbc_exec()超时的任何信息.它默认为无限等待吗?
I've been unable to find anything in the PHP documentation regarding how to set the timeout for odbc_exec(). Does it default to an infinite wait?
推荐答案
在这里您只能做很多事情. PHP的默认脚本执行时间设置为30秒.有很多更改方法,包括set_time_limit()
函数(可在手册中找到),以及通过使用ini_set
或使用odbc_setoption
There's only so much you can do here. PHP's default script execution time is set to 30 seconds. There are numerous ways to change this, including the set_time_limit()
function (found in the manual), and extending execution time by using ini_set
, or using odbc_setoption
//extend execution time
$num_minutes = 5;
ini_set('max_execution_time', (60*$num_minutes)); //set timeout to 5 minutes
您还可以在php.ini文件中更改此设置.但是,所有这些都只能控制apache服务器可以控制的范围.如果数据库本身存在超时,即使您个人设置的执行时间增加了,它仍然会切断您的呼叫并返回错误.
You can also change this setting inside your php.ini file. However, all of these only control the scope within what your apache server can control. If the database itself has a timeout, it will still cut off your call and return an error, even if your personally set execution times are elevated.
这篇关于如何管理PHP odbc_exec超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!