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