1--TEST--
2PDO MySQL PECL bug #1295 (http://pecl.php.net/bugs/bug.php?id=12925)
3--EXTENSIONS--
4pdo
5pdo_mysql
6--SKIPIF--
7<?php
8require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
9MySQLPDOTest::skip();
10$db = MySQLPDOTest::factory();
11?>
12--FILE--
13<?php
14require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
15$db = MySQLPDOTest::factory();
16
17function bug_pecl_1295($db) {
18
19    $db->exec('DROP TABLE IF EXISTS test');
20    $db->exec('CREATE TABLE test(id CHAR(1))');
21    $db->exec("INSERT INTO test(id) VALUES ('a')");
22    $stmt = $db->prepare("UPDATE test SET id = 'b'");
23    $stmt->execute();
24    $stmt = $db->prepare("UPDATE test SET id = 'c'");
25    $stmt->execute();
26    $stmt = $db->prepare('SELECT id FROM test');
27    $stmt->execute();
28    var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
29    $stmt->closeCursor();
30
31}
32
33printf("Emulated...\n");
34$db = MySQLPDOTest::factory();
35$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
36bug_pecl_1295($db);
37
38printf("Native...\n");
39$db = MySQLPDOTest::factory();
40$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
41bug_pecl_1295($db);
42
43$db->exec('DROP TABLE IF EXISTS test');
44print "done!";
45?>
46--EXPECT--
47Emulated...
48array(1) {
49  [0]=>
50  array(1) {
51    ["id"]=>
52    string(1) "c"
53  }
54}
55Native...
56array(1) {
57  [0]=>
58  array(1) {
59    ["id"]=>
60    string(1) "c"
61  }
62}
63done!
64