reference/mysqli/mysqli_stmt/store-result.xml
63b99082ef83eade08151f8cb528246fded81db9
...
...
@@ -4,33 +4,33 @@
4
4
<refnamediv>
5
5
<refname>mysqli_stmt::store_result</refname>
6
6
<refname>mysqli_stmt_store_result</refname>
7
-
<refpurpose>Transfers a result set from a prepared statement</refpurpose>
7
+
<refpurpose>Stores a result set in an internal buffer</refpurpose>
8
8
</refnamediv>
9
9

10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<para>&style.oop;</para>
13
-
<methodsynopsis role="oop">
14
-
<type>bool</type><methodname>mysqli_stmt::store_result</methodname>
15
-
<void />
13
+
<methodsynopsis role="mysqli_stmt">
14
+
<modifier>public</modifier> <type>bool</type><methodname>mysqli_stmt::store_result</methodname>
15
+
<void/>
16
16
</methodsynopsis>
17
17
<para>&style.procedural;</para>
18
18
<methodsynopsis>
19
19
<type>bool</type><methodname>mysqli_stmt_store_result</methodname>
20
-
<methodparam><type>mysqli_stmt</type><parameter>stmt</parameter></methodparam>
20
+
<methodparam><type>mysqli_stmt</type><parameter>statement</parameter></methodparam>
21
21
</methodsynopsis>
22
22
<para>
23
-
You must call <function>mysqli_stmt_store_result</function> for every query that
24
-
successfully produces a result set (<literal>SELECT, SHOW, DESCRIBE, EXPLAIN</literal>),
25
-
if and only if you want to buffer the complete result set by the client,
26
-
so that the subsequent <function>mysqli_stmt_fetch</function> call returns buffered data.
23
+
This function should be called for queries that successfully
24
+
produce a result set (e.g. <literal>SELECT, SHOW, DESCRIBE, EXPLAIN</literal>)
25
+
only if the complete result set needs to be buffered in PHP. Each subsequent
26
+
<function>mysqli_stmt_fetch</function> call will return buffered data.
27
27
</para>
28
28
<note>
29
29
<para>
30
30
It is unnecessary to call <function>mysqli_stmt_store_result</function> for other queries,
31
31
but if you do, it will not harm or cause any notable performance loss in all cases.
32
32
You can detect whether the query produced a result set by checking if
33
-
<function>mysqli_stmt_result_metadata</function> returns NULL.
33
+
<function>mysqli_stmt_result_metadata</function> returns &false;.
34
34
</para>
35
35
</note>
36
36
</refsect1>
...
...
@@ -51,6 +51,11 @@
51
51
</para>
52
52
</refsect1>
53
53

54
+
<refsect1 role="errors">
55
+
&reftitle.errors;
56
+
&mysqli.conditionalexception;
57
+
</refsect1>
58
+

54
59
<refsect1 role="examples">
55
60
&reftitle.examples;
56
61
<example>
...
...
@@ -58,36 +63,18 @@
58
63
<programlisting role="php">
59
64
<![CDATA[
60
65
<?php
61
-
/* Open a connection */
62
-
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
63
66

64
-
/* check connection */
65
-
if (mysqli_connect_errno()) {
66
-
printf("Connect failed: %s\n", mysqli_connect_error());
67
-
exit();
68
-
}
67
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
68
+
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
69
69

70
70
$query = "SELECT Name, CountryCode FROM City ORDER BY Name LIMIT 20";
71
-
if ($stmt = $mysqli->prepare($query)) {
72
-

73
-
/* execute query */
74
-
$stmt->execute();
75
-

76
-
/* store result */
77
-
$stmt->store_result();
78
-

79
-
printf("Number of rows: %d.\n", $stmt->num_rows);
80
-

81
-
/* free result */
82
-
$stmt->free_result();
71
+
$stmt = $mysqli->prepare($query);
72
+
$stmt->execute();
83
73

84
-
/* close statement */
85
-
$stmt->close();
86
-
}
74
+
/* store the result in an internal buffer */
75
+
$stmt->store_result();
87
76

88
-
/* close connection */
89
-
$mysqli->close();
90
-
?>
77
+
printf("Number of rows: %d.\n", $stmt->num_rows);
91
78
]]>
92
79
</programlisting>
93
80
</example>
...
...
@@ -96,36 +83,18 @@ $mysqli->close();
96
83
<programlisting role="php">
97
84
<![CDATA[
98
85
<?php
99
-
/* Open a connection */
100
-
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
101
86

102
-
/* check connection */
103
-
if (mysqli_connect_errno()) {
104
-
printf("Connect failed: %s\n", mysqli_connect_error());
105
-
exit();
106
-
}
87
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
88
+
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
107
89

108
90
$query = "SELECT Name, CountryCode FROM City ORDER BY Name LIMIT 20";
109
-
if ($stmt = mysqli_prepare($link, $query)) {
110
-

111
-
/* execute query */
112
-
mysqli_stmt_execute($stmt);
113
-

114
-
/* store result */
115
-
mysqli_stmt_store_result($stmt);
91
+
$stmt = mysqli_prepare($link, $query);
92
+
mysqli_stmt_execute($stmt);
116
93

117
-
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
94
+
/* store the result in an internal buffer */
95
+
mysqli_stmt_store_result($stmt);
118
96

119
-
/* free result */
120
-
mysqli_stmt_free_result($stmt);
121
-

122
-
/* close statement */
123
-
mysqli_stmt_close($stmt);
124
-
}
125
-

126
-
/* close connection */
127
-
mysqli_close($link);
128
-
?>
97
+
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
129
98
]]>
130
99
</programlisting>
131
100
&examples.outputs;
...
...
@@ -149,7 +118,6 @@ Number of rows: 20.
149
118
</refsect1>
150
119

151
120
</refentry>
152
-

153
121
<!-- Keep this comment at the end of the file
154
122
Local variables:
155
123
mode: sgml
156
124