reference/mysqli/mysqli_stmt/store-result.xml
63b99082ef83eade08151f8cb528246fded81db9
...
...
@@ -4,26 +4,26 @@
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">
13
+
<methodsynopsis role="mysqli_stmt">
14
14
<modifier>public</modifier> <type>bool</type><methodname>mysqli_stmt::store_result</methodname>
15
15
<void/>
16
16
</methodsynopsis>
17
17
<para>&style.procedural;</para>
18
-
<methodsynopsis role="procedural">
18
+
<methodsynopsis>
19
19
<type>bool</type><methodname>mysqli_stmt_store_result</methodname>
20
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>
...
...
@@ -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);
71
+
$stmt = $mysqli->prepare($query);
72
+
$stmt->execute();
80
73

81
-
/* free result */
82
-
$stmt->free_result();
74
+
/* store the result in an internal buffer */
75
+
$stmt->store_result();
83
76

84
-
/* close statement */
85
-
$stmt->close();
86
-
}
87
-

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);
116
-

117
-
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
118
-

119
-
/* free result */
120
-
mysqli_stmt_free_result($stmt);
91
+
$stmt = mysqli_prepare($link, $query);
92
+
mysqli_stmt_execute($stmt);
121
93

122
-
/* close statement */
123
-
mysqli_stmt_close($stmt);
124
-
}
94
+
/* store the result in an internal buffer */
95
+
mysqli_stmt_store_result($stmt);
125
96

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;
132
101