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