10
On a connection to an external server (MS SQL SERVER), from another system with which I integrate some data, it is extremely slow, and with that the connection with the database gives error.
How to increase connection timeout dblib with PDO?
I tried to use array(\PDO::ATTR_TIMEOUT => 10)
as an option on the connection PDO but generates the following error:
Warning: PDO::__Construct(): SQLSTATE[IM001]: Driver does not support this Function: driver does not support Setting Attributes in /var/www/core/class/Banco/Gkbanco.php on line 25
How to connect to MSSQL
with a larger timeout? can be using any lib that works with linux.
I tried to use setAttribute(\PDO::ATTR_TIMEOUT, 10);
and generates the following error:
Warning: PDO::setAttribute(): SQLSTATE[IM001]: Driver does not support this Function: driver does not support Setting Attributes
I tried to add ini_set("default_socket_timeout", 30);
before connection did not change anything.
Ever tried to use
PDO::setAttribute
?– stderr
Also not working: Warning: PDO::setAttribute(): SQLSTATE[IM001]: Driver does not support this Function: driver does not support Setting Attributes
– Allan Andrade
In that case it may be necessary to use another driver, using
PDO::getAvailableDrivers
returns the drivers available. Before choosing one, check if it supports thesetAttribute
. See the list of drivers here.– stderr
@stderr, knowing that PDO_SQLSRV only works on Windows servers, which other option I have for connection to MSSQL Server ?
– Allan Andrade
According to the documentation, the option is PDO_ODBC, see also this page on msdn for more details.
– stderr
Try to put
ini_set("default_socket_timeout", 10);
before connection.– Augusto
@Augusto, thank you for your help, but you haven’t changed a bit.
– Allan Andrade