Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP PDO: Set FireBird connection timeout

I'm connecting to a FireBird database, which works fine when the database is online. When the server is offline, the user gets an max execution time passed error.

Therefore I want to surround the connection statement with a try catch and set the timeout to 10 seconds. But I can't find the right attribute to do so. The default ATTR_TIMEOUT doesn't seem to work. Can anyone tell me if this is possible with PDO and FireBird?

like image 580
Rob Avatar asked Oct 19 '25 08:10

Rob


1 Answers

Not sure about PHP / PDO but there is ConnectionTimeout parameter in the firebird.conf file you could try. The default value is 180 seconds (quote from conf file):

# ----------------------------
# Client Connection Settings (Basic)
#
# Seconds to wait before concluding an attempt to connect has failed.
#
# Type: integer
#
#ConnectionTimeout = 180

If your FireBird server is not in the same server where the PHP script runs and you don't have firebird.conf file on the "PHP server", then try to put one into same directory where the fbclient dll is. Or if there is FIREBIRD enviroment variable defined, then into the directory that var points to.

like image 66
ain Avatar answered Oct 20 '25 23:10

ain