未捕获的异常' PDOException'消息' SQLSTATE [7]超时到期

时间:2016-11-10 14:35:59

标签: php postgresql pdo

当我尝试在Windows上通过PHP连接postgresql时,我收到此错误消息

Warning: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] timeout expired' in C:\Apache24\htdocs\projetbdd\reconcept.php:2 Stack trace: #0 C:\Apache24\htdocs\projetbdd\reconcept.php(2): PDO->__construct('pgsql:host=loca...', 'postgres', 'momocrosse') #1 {main} thrown in C:\Apache24\htdocs\projetbdd\reconcept.php on line 2

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Apache24\htdocs\projetbdd\reconcept.php on line 2

1 个答案:

答案 0 :(得分:0)

您可以使用以下方式指定连接的超时持续时间:

$connection->setAttribute(PDO::ATTR_TIMEOUT, 15);

表单更多细节请参阅此页面: http://php.net/manual/en/pdo.setattribute.php