xref: /PHP-5.4/ext/pdo_mysql/tests/bug_45120.phpt (revision e2efe4bc)
1--TEST--
2Bug #45120 (PDOStatement->execute() returns true then false for same statement)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) 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__) . '/config.inc';
13require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
14$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
15
16function bug_45120($db) {
17
18	$stmt = $db->prepare("SELECT 1 AS 'one'");
19	if (true !== $stmt->execute())
20		printf("[001] Execute has failed: %s\n", var_export($stmt->errorInfo(), true));
21
22	$res = $stmt->fetch(PDO::FETCH_ASSOC);
23	if ($res['one'] != 1)
24		printf("[002] Wrong results: %s\n", var_export($res, true));
25
26	if (true !== $stmt->execute())
27		printf("[003] Execute has failed: %s\n", var_export($stmt->errorInfo(), true));
28
29	$res = $stmt->fetch(PDO::FETCH_ASSOC);
30	if ($res['one'] != 1)
31		printf("[004] Wrong results: %s\n", var_export($res, true));
32
33}
34
35print "Emulated Prepared Statements\n";
36$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
37bug_45120($db);
38
39print "Native Prepared Statements\n";
40$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
41bug_45120($db);
42
43print "done!";
44?>
45--EXPECT--
46Emulated Prepared Statements
47Native Prepared Statements
48done!
49