xref: /PHP-5.3/ext/pdo_mysql/tests/bug44327.phpt (revision 973d7bad)
1--TEST--
2Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
3--SKIPIF--
4<?php
5require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7MySQLPDOTest::skip();
8$db = MySQLPDOTest::factory();
9?>
10--FILE--
11<?php
12	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
13	$db = MySQLPDOTest::factory();
14
15	$stmt = $db->prepare("SELECT 1 AS \"one\"");
16	$stmt->execute();
17	$row = $stmt->fetch(PDO::FETCH_LAZY);
18	var_dump($row);
19	var_dump($row->{0});
20	var_dump($row->one);
21	var_dump($row->queryString);
22
23	print "----------------------------------\n";
24
25	@$db->exec("DROP TABLE test");
26	$db->exec("CREATE TABLE test (id INT)");
27	$db->exec("INSERT INTO test(id) VALUES (1)");
28	$stmt = $db->prepare("SELECT id FROM test");
29	$stmt->execute();
30	$row = $stmt->fetch(PDO::FETCH_LAZY);
31	var_dump($row);
32	var_dump($row->queryString);
33	@$db->exec("DROP TABLE test");
34
35	print "----------------------------------\n";
36
37	$stmt = $db->prepare('foo');
38	@$stmt->execute();
39	$row = $stmt->fetch();
40	var_dump($row->queryString);
41
42?>
43--EXPECTF--
44object(PDORow)#%d (2) {
45  [%u|b%"queryString"]=>
46  %unicode|string%(17) "SELECT 1 AS "one""
47  [%u|b%"one"]=>
48  %unicode|string%(1) "1"
49}
50%unicode|string%(1) "1"
51%unicode|string%(1) "1"
52%unicode|string%(17) "SELECT 1 AS "one""
53----------------------------------
54object(PDORow)#%d (2) {
55  [%u|b%"queryString"]=>
56  %unicode|string%(19) "SELECT id FROM test"
57  [%u|b%"id"]=>
58  %unicode|string%(1) "1"
59}
60%unicode|string%(19) "SELECT id FROM test"
61----------------------------------
62
63Notice: Trying to get property of non-object in %s on line %d
64NULL
65