Skip to content

Commit bba9bc6

Browse files
committed
Set non-default error mode to maintain expected behavior
1 parent e295266 commit bba9bc6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/pdo_dblib/tests/timeout.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ if ($stmt->execute()) {
2020

2121
// regular timeout attribute, set after instance created, will affect query timeout, causing this query to fail
2222
$db = new PDO($dsn, $user, $pass);
23+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
2324
$db->setAttribute(PDO::ATTR_TIMEOUT, 1);
2425
$stmt = $db->prepare($sql);
2526
if (!$stmt->execute()) {
@@ -33,6 +34,7 @@ if (!$stmt->execute()) {
3334

3435
// pdo_dblib-specific timeout attribute, set after instance created, will control query timeout, causing this query to fail
3536
$db = new PDO($dsn, $user, $pass);
37+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
3638
$db->setAttribute(PDO::DBLIB_ATTR_QUERY_TIMEOUT, 1);
3739
$stmt = $db->prepare($sql);
3840
if (!$stmt->execute()) {
@@ -45,7 +47,7 @@ if (!$stmt->execute()) {
4547
}
4648

4749
// regular timeout attribute will affect query timeout, causing this query to fail
48-
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_TIMEOUT => 1]);
50+
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::ATTR_TIMEOUT => 1]);
4951
$stmt = $db->prepare($sql);
5052
if (!$stmt->execute()) {
5153
echo "OK\n";
@@ -57,7 +59,7 @@ if (!$stmt->execute()) {
5759
}
5860

5961
// pdo_dblib-specific timeout attribute will control query timeout, causing this query to fail
60-
$db = new PDO($dsn, $user, $pass, [PDO::DBLIB_ATTR_QUERY_TIMEOUT => 1]);
62+
$db = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT, PDO::DBLIB_ATTR_QUERY_TIMEOUT => 1]);
6163
$stmt = $db->prepare($sql);
6264
if (!$stmt->execute()) {
6365
echo "OK\n";

0 commit comments

Comments
 (0)