xref: /PHP-8.0/ext/pdo/tests/bug_72368.phpt (revision 9e3ba775)
1--TEST--
2PDO Common: Bug #72368 (PdoStatement->execute() fails but does not throw an exception)
3--SKIPIF--
4<?php # vim:ft=php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8require_once $dir . 'pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15$db = PDOTest::factory();
16$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
17
18$params = [":bar" => 1];
19$sql = "SELECT 1";
20
21$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
22try {
23	$stmt = $db->prepare($sql);
24	var_dump($stmt->execute($params));
25} catch (PDOException $e) {
26	var_dump('ERR');
27}
28
29
30$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
31try {
32	$stmt = $db->prepare($sql);
33	var_dump($stmt->execute($params));
34} catch (PDOException $e) {
35	var_dump('ERR');
36}
37
38?>
39===DONE===
40--EXPECT--
41string(3) "ERR"
42string(3) "ERR"
43===DONE===
44