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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
--TEST--
magic_quotes_runtime (DEPRECATED)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (version_compare(PHP_VERSION, '5.3.98') >= 0) {
die("skip: PHP 5.3 test");
}
?>
--INI--
magic_quotes_runtime=1
--FILE--
<?php
require('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
$query = sprintf("SELECT '%s', '%s', '%s', '%s' FROM DUAL",
mysqli_real_escape_string($link, "'"),
mysqli_real_escape_string($link, '"'),
mysqli_real_escape_string($link, '\0'),
mysqli_real_escape_string($link, '\\'));
if (!$res = mysqli_query($link, $query)) {
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
while ($row = $res->fetch_assoc()) {
var_dump($row);
}
$res->free();
$expected = array(
"'" => "\\'",
'"' => "\\\"",
"\\0" => "\\\\0",
"\\" => "\\\\",
);
$expectedBoth = array(
0 => "\\'",
"'" => "\\'",
1 => "\\\"",
'"' => "\\\"",
2 => "\\\\0",
"\\0" => "\\\\0",
3 => "\\\\",
"\\" => "\\\\",
);
if (!$res = mysqli_query($link, $query)) {
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
$row = mysqli_fetch_row($res);
echo "Equal:";var_dump($row === array_values($expected));
if ($row !== array_values($expected)) {
var_dump($row, array_values($expected));
}
$res->free();
if (!$res = mysqli_query($link, $query)) {
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
$row = mysqli_fetch_array($res, MYSQLI_BOTH);
echo "Equal:";var_dump($row === $expectedBoth);
if ($row !== $expectedBoth) {
var_dump($row, $expectedBoth);
}
$res->free();
class fetch_object {
public function __set($key, $value) {
printf(">%s< => >%s<\n", $key, $value);
}
}
if (!$res = mysqli_query($link, $query)) {
printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
$obj = mysqli_fetch_object($res, "fetch_object");
$res->free();
if (false && $IS_MYSQLND) {
if (!$res = mysqli_query($link, $query)) {
printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
$row = @mysqli_fetch_all($res, MYSQLI_ASSOC);
if ($row[0] !== $expected) {
printf("[015] Wrong data, dumping\n");
var_dump($row);
}
}
$link->close();
print "done!";
?>
--EXPECTF--
Deprecated: Directive 'magic_quotes_runtime' is deprecated in PHP 5.3 and greater in Unknown on line %d
Warning: mysqli_result::fetch_assoc(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
array(4) {
["'"]=>
string(2) "\'"
["""]=>
string(2) "\""
["\0"]=>
string(3) "\\0"
["\"]=>
string(2) "\\"
}
Warning: mysqli_fetch_row(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
Equal:bool(true)
Warning: mysqli_fetch_array(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
Equal:bool(true)
Warning: mysqli_fetch_object(): magic_quotes_runtime are deprecated since PHP 5.3 in %s on line %d
>'< => >\'<
>"< => >\"<
>\0< => >\\0<
>\< => >\\<
done!
|