Skip to content

Commit 69d9c12

Browse files
Fix mysqli_stmt_get_result.phpt (#15495)
1 parent 660a860 commit 69d9c12

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

ext/mysqli/tests/mysqli_stmt_get_result.phpt

+25-27
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ require_once 'skipifconnectfailure.inc';
2828
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
2929
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
3030

31-
// FIXME - different versions return different values ?!
32-
if ((NULL !== ($tmp = mysqli_stmt_get_result($stmt))) && (false !== $tmp))
33-
printf("[006] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
31+
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
32+
printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
3433

3534
if (!mysqli_stmt_execute($stmt))
3635
printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -39,7 +38,7 @@ require_once 'skipifconnectfailure.inc';
3938
printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
4039

4140
if (is_object($tmp = mysqli_stmt_store_result($stmt)))
42-
printf("[009] non-object, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
41+
printf("[009] non-object, got %s/%s\n", gettype($tmp), var_export($tmp, true));
4342

4443
mysqli_stmt_close($stmt);
4544

@@ -56,15 +55,14 @@ require_once 'skipifconnectfailure.inc';
5655
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
5756
printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
5857

59-
// FIXME - different versions return different values ?!
60-
if ((NULL !== ($tmp = mysqli_stmt_get_result($stmt))) && (false !== $tmp))
61-
printf("[013] Expecting NULL or boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
58+
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
59+
printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
6260

6361
if (!mysqli_stmt_execute($stmt))
6462
printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
6563

66-
if (!is_object($tmp = mysqli_stmt_get_result($stmt)))
67-
printf("[016] NULL, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
64+
if (! ($tmp = mysqli_stmt_get_result($stmt)) instanceof mysqli_result)
65+
printf("[016] Expecting mysqli_result, got %s/%s\n", gettype($tmp), var_export($tmp, true));
6866

6967
mysqli_free_result($tmp);
7068
mysqli_stmt_close($stmt);
@@ -83,25 +81,25 @@ require_once 'skipifconnectfailure.inc';
8381
printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
8482

8583
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
86-
printf("[020] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
84+
printf("[020] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
8785

8886
if (!mysqli_stmt_execute($stmt))
8987
printf("[023] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
9088

91-
if (!is_object($tmp = mysqli_stmt_get_result($stmt)))
92-
printf("[024] Expecting object, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
89+
if (! ($tmp = mysqli_stmt_get_result($stmt)) instanceof mysqli_result)
90+
printf("[024] Expecting mysqli_result, got %s/%s\n", gettype($tmp), var_export($tmp, true));
9391

9492
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
95-
printf("[025] false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
93+
printf("[025] false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
9694

9795
if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) {
9896
printf("[026] [%d] [%s]\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
9997
printf("[027] [%d] [%s]\n", mysqli_errno($link), mysqli_error($link));
100-
printf("[028] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
98+
printf("[028] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, true));
10199
}
102100

103101
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
104-
printf("[029] false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
102+
printf("[029] false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
105103

106104
mysqli_stmt_close($stmt);
107105

@@ -135,11 +133,11 @@ require_once 'skipifconnectfailure.inc';
135133
$id = NULL;
136134
$label = NULL;
137135
if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label)))
138-
printf("[037] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
136+
printf("[037] Expecting boolean/true, got %s/%s\n", gettype($tmp), var_export($tmp, true));
139137

140-
if (!is_object($tmp = $result = mysqli_stmt_get_result($stmt)))
141-
printf("[038] Expecting array, got %s/%s, [%d] %s\n",
142-
gettype($tmp), var_export($tmp, 1),
138+
if (! ($result = mysqli_stmt_get_result($stmt)) instanceof mysqli_result)
139+
printf("[038] Expecting mysqli_result, got %s/%s, [%d] %s\n",
140+
gettype($result), var_export($result, true),
143141
mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
144142

145143
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
@@ -155,23 +153,23 @@ require_once 'skipifconnectfailure.inc';
155153

156154
$link->real_query('KILL '.mysqli_thread_id($link));
157155
// We kill our own connection so we should get "Query execution was interrupted"
158-
if ($link->errno !== 1317)
159-
printf("[042] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
156+
if ($link->errno !== 1317)
157+
printf("[042] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
160158

161-
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
162-
printf("[043] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
159+
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
160+
printf("[043] Expecting boolean/false, got %s/%s\n", gettype($tmp), var_export($tmp, true));
163161

164-
mysqli_stmt_close($stmt);
162+
mysqli_stmt_close($stmt);
165163

166-
try {
164+
try {
167165
mysqli_stmt_fetch($stmt);
168166
} catch (Error $exception) {
169167
echo $exception->getMessage(), "\n";
170168
}
171169

172-
mysqli_close($link);
170+
mysqli_close($link);
173171

174-
print "done!";
172+
print "done!";
175173
?>
176174
--CLEAN--
177175
<?php

0 commit comments

Comments
 (0)