Skip to content

Commit 8abf640

Browse files
Improve the documentation of mysqli_stmt_result_metadata() (#4912)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
1 parent b68b5e4 commit 8abf640

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

reference/mysqli/mysqli_stmt/result-metadata.xml

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@
2525
that can be used to process the meta information such as total number of fields
2626
and individual field information.
2727
</para>
28+
<simpara>
29+
This function returns an empty <classname>mysqli_result</classname> object
30+
which can be used to access metadata information from the prepared statement
31+
without having to fetch the actual rows of data. There is no need to use
32+
this function when using <function>mysqli_stmt_get_result</function> to
33+
retrieve the entire result set from a prepared statement as a result object.
34+
</simpara>
2835
<note>
29-
<para>This result set pointer can be passed as an argument to any of the
36+
<para>
37+
This result set object can be passed as an argument only to the
3038
field-based functions that process result set metadata, such as:
3139
<itemizedlist>
3240
<listitem><para><function>mysqli_num_fields</function></para></listitem>
@@ -40,16 +48,13 @@
4048
</itemizedlist>
4149
</para>
4250
</note>
43-
<para>
44-
The result set structure should be freed when you are done with it,
45-
which you can do by passing it to <function>mysqli_free_result</function>
46-
</para>
4751
<note>
48-
<para>
49-
The result set returned by <function>mysqli_stmt_result_metadata</function> contains only
50-
metadata. It does not contain any row results. The rows are obtained by using the
51-
statement handle with <function>mysqli_stmt_fetch</function>.
52-
</para>
52+
<simpara>
53+
The result set returned by <function>mysqli_stmt_result_metadata</function>
54+
contains only metadata. It does not contain any row results.
55+
The rows are obtained by calling <function>mysqli_stmt_get_result</function>
56+
on the statement handle or with <function>mysqli_stmt_fetch</function>.
57+
</simpara>
5358
</note>
5459
</refsect1>
5560

@@ -64,9 +69,10 @@
6469

6570
<refsect1 role="returnvalues">
6671
&reftitle.returnvalues;
67-
<para>
72+
<simpara>
6873
Returns a result object or &false; if an error occurred.
69-
</para>
74+
If the statement does not produce a result set, &false; is returned as well.
75+
</simpara>
7076
</refsect1>
7177

7278
<refsect1 role="errors">
@@ -98,12 +104,6 @@ $result = $stmt->result_metadata();
98104
$field = $result->fetch_field();
99105
100106
printf("Fieldname: %s\n", $field->name);
101-
102-
/* close resultset */
103-
$result->close();
104-
105-
/* close connection */
106-
$mysqli->close();
107107
?>
108108
]]>
109109
</programlisting>
@@ -130,12 +130,6 @@ $result = mysqli_stmt_result_metadata($stmt);
130130
$field = mysqli_fetch_field($result);
131131
132132
printf("Fieldname: %s\n", $field->name);
133-
134-
/* close resultset */
135-
mysqli_free_result($result);
136-
137-
/* close connection */
138-
mysqli_close($link);
139133
?>
140134
]]>
141135
</programlisting>
@@ -148,6 +142,7 @@ mysqli_close($link);
148142
<simplelist>
149143
<member><function>mysqli_prepare</function></member>
150144
<member><function>mysqli_free_result</function></member>
145+
<member><function>mysqli_stmt_get_result</function></member>
151146
</simplelist>
152147
</para>
153148
</refsect1>

0 commit comments

Comments
 (0)