SQLite3::busyTimeout

(PHP 5 >= 5.3.3, PHP 7)

SQLite3::busyTimeoutSets the busy connection handler

说明

public SQLite3::busyTimeout ( int $msecs ) : bool

Sets a busy handler that will sleep until the database is not locked or the timeout is reached.

参数

msecs

The milliseconds to sleep. Setting this value to a value less than or equal to zero, will turn off an already set timeout handler.

返回值

Returns TRUE on success, 或者在失败时返回 FALSE.

User Contributed Notes

dkarnout at gmail dot com 14-Aug-2015 06:40
For SQLite2 (http://php.net/manual/en/function.sqlite-busy-timeout.php), PHP sets the default busy timeout to be 60 seconds when the database is opened.
However, this does not happen for v3 and it has to be done manually.

My personal experience is that the default value of SQLite3, which is 0, is not enough when you have to do consecutive read/write commits and the file has not been accessed for long time.
ppryor63 at gmail dot com 13-Feb-2014 01:30
The busyTimeout() method and related API sqlite3_busy_timeout() is a connection level attribute and affects whole connection and should be set once after opening connection.  Do not set to zero or you will encounter "Database is busy" error message when calling query, querySingle, prepare, or execute methods.  Also ensure that sqlite3 library is compiled with HAVE_USLEEP defined, otherwise busyTimeout() can only time out in seconds.  It is very highly recommended to call busyTimeout() with non-zero timeout for reliability in concurrent environment.