mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
c18b1aea28
Previously, PDO MySQL only fetched data as native int/float if native prepared statements were used. This patch updates PDO to have the same behavior for emulated prepared statements, and thus removes the largest remaining discrepancy between these two modes. Note that PDO already has a ATTR_STRINGIFY_FETCHES option to control whether native types are desired or not. The previous output can be restored by enabling this option. Most of the tests make use of that option, because this allows the tests to work under libmysqlclient as well, which currently always returns string results (independently of whether native or emulated PS are used).
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
--TEST--
|
|
Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
|
|
--SKIPIF--
|
|
<?php
|
|
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc');
|
|
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
|
MySQLPDOTest::skip();
|
|
$db = MySQLPDOTest::factory();
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
|
$db = MySQLPDOTest::factory();
|
|
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
|
|
|
$stmt = $db->prepare("SELECT 1 AS \"one\"");
|
|
$stmt->execute();
|
|
$row = $stmt->fetch(PDO::FETCH_LAZY);
|
|
var_dump($row);
|
|
var_dump($row->{0});
|
|
var_dump($row->one);
|
|
var_dump($row->queryString);
|
|
|
|
print "----------------------------------\n";
|
|
|
|
@$db->exec("DROP TABLE test");
|
|
$db->exec("CREATE TABLE test (id INT)");
|
|
$db->exec("INSERT INTO test(id) VALUES (1)");
|
|
$stmt = $db->prepare("SELECT id FROM test");
|
|
$stmt->execute();
|
|
$row = $stmt->fetch(PDO::FETCH_LAZY);
|
|
var_dump($row);
|
|
var_dump($row->queryString);
|
|
@$db->exec("DROP TABLE test");
|
|
|
|
print "----------------------------------\n";
|
|
|
|
$stmt = $db->prepare('foo');
|
|
@$stmt->execute();
|
|
$row = $stmt->fetch();
|
|
var_dump($row->queryString);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
object(PDORow)#%d (2) {
|
|
["queryString"]=>
|
|
string(17) "SELECT 1 AS "one""
|
|
["one"]=>
|
|
string(1) "1"
|
|
}
|
|
string(1) "1"
|
|
string(1) "1"
|
|
string(17) "SELECT 1 AS "one""
|
|
----------------------------------
|
|
object(PDORow)#5 (2) {
|
|
["queryString"]=>
|
|
string(19) "SELECT id FROM test"
|
|
["id"]=>
|
|
string(1) "1"
|
|
}
|
|
string(19) "SELECT id FROM test"
|
|
----------------------------------
|
|
|
|
Warning: Attempt to read property "queryString" on bool in %s on line %d
|
|
NULL
|