]> granicus.if.org Git - php/commitdiff
Set non-default error mode to maintain expected behavior
authorAdam Baratz <adambaratz@php.net>
Fri, 8 May 2020 18:45:37 +0000 (14:45 -0400)
committerAdam Baratz <adambaratz@php.net>
Fri, 8 May 2020 18:45:37 +0000 (14:45 -0400)
ext/pdo_dblib/tests/timeout.phpt

index 2ef20fd4fc177d49f75ebe5016e7a2c19a214748..a070b0da7503c83f6108f59e7e7c926df0856197 100644 (file)
@@ -20,6 +20,7 @@ if ($stmt->execute()) {
 
 // regular timeout attribute, set after instance created, will affect query timeout, causing this query to fail
 $db = new PDO($dsn, $user, $pass);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
 $db->setAttribute(PDO::ATTR_TIMEOUT, 1);
 $stmt = $db->prepare($sql);
 if (!$stmt->execute()) {
@@ -33,6 +34,7 @@ if (!$stmt->execute()) {
 
 // pdo_dblib-specific timeout attribute, set after instance created, will control query timeout, causing this query to fail
 $db = new PDO($dsn, $user, $pass);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
 $db->setAttribute(PDO::DBLIB_ATTR_QUERY_TIMEOUT, 1);
 $stmt = $db->prepare($sql);
 if (!$stmt->execute()) {
@@ -45,7 +47,7 @@ if (!$stmt->execute()) {
 }
 
 // regular timeout attribute will affect query timeout, causing this query to fail
-$db = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 1]);
+$db = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::ATTR_TIMEOUT => 1]);
 $stmt = $db->prepare($sql);
 if (!$stmt->execute()) {
     echo "OK\n";
@@ -57,7 +59,7 @@ if (!$stmt->execute()) {
 }
 
 // pdo_dblib-specific timeout attribute will control query timeout, causing this query to fail
-$db = new PDO($dsn, $user, $pass, [PDO::DBLIB_ATTR_QUERY_TIMEOUT => 1]);
+$db = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::DBLIB_ATTR_QUERY_TIMEOUT => 1]);
 $stmt = $db->prepare($sql);
 if (!$stmt->execute()) {
     echo "OK\n";