xref: /PHP-8.2/ext/pdo_pgsql/tests/bug70313.phpt (revision 39131219)
1--TEST--
2PDO PgSQL Bug #70313 (PDO statement fails to throw exception)
3--EXTENSIONS--
4pdo
5pdo_pgsql
6--SKIPIF--
7<?php
8require __DIR__ . '/config.inc';
9require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
15$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
16$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
17
18$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
19try {
20    $stmt = $db->prepare(");");
21
22    $stmt->execute([1]);
23} catch (PDOException $e) {
24    echo $e->getMessage(), "\n";
25}
26
27$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
28try {
29    $stmt = $db->prepare(");");
30
31    $stmt->execute([1]);
32} catch (PDOException $e) {
33    echo $e->getMessage(), "\n";
34}
35
36?>
37--EXPECTF--
38SQLSTATE[42601]: Syntax error: %A
39SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
40