xref: /PHP-7.1/ext/pdo_pgsql/tests/bug70313.phpt (revision 219ebcb6)
1--TEST--
2PDO PgSQL Bug #70313 (PDO statement fails to throw exception)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6require dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
14$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
15
16$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
17try {
18	$stmt = $db->prepare(");");
19
20	$stmt->execute([1]);
21} catch (PDOException $e) {
22	var_dump($e->getCode());
23}
24
25$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
26try {
27	$stmt = $db->prepare(");");
28
29	$stmt->execute([1]);
30} catch (PDOException $e) {
31	var_dump($e->getCode());
32}
33
34?>
35--EXPECT--
36string(5) "42601"
37string(5) "42601"
38