Updating mysqli: mysqli_num_fields

* Aligned wording
* Explicitely list columns to make it obvious where the number comes from

Closes GH-892.
This commit is contained in:
Kamil Tekiela 2021-09-03 14:59:33 +01:00 committed by GitHub
parent aa19c140e6
commit a3051835f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@
<refnamediv>
<refname>mysqli_result::$field_count</refname>
<refname>mysqli_num_fields</refname>
<refpurpose>Get the number of fields in a result</refpurpose>
<refpurpose>Gets the number of fields in the result set</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -17,7 +17,7 @@
<methodparam><type>mysqli_result</type><parameter>result</parameter></methodparam>
</methodsynopsis>
<para>
Returns the number of fields from specified result set.
Returns the number of fields in the result set.
</para>
</refsect1>
@ -33,7 +33,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The number of fields from a result set.
An <type>int</type> representing the number of fields.
</para>
</refsect1>
@ -44,28 +44,16 @@
<programlisting role="php">
<![CDATA[
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query("SELECT Name, CountryCode, District, Population FROM City ORDER BY ID LIMIT 1");
if ($result = $mysqli->query("SELECT * FROM City ORDER BY ID LIMIT 1")) {
/* Get the number of fields in the result set */
$field_cnt = $result->field_count;
/* determine number of fields in result set */
$field_cnt = $result->field_count;
printf("Result set has %d fields.\n", $field_cnt);
/* close result set */
$result->close();
}
/* close connection */
$mysqli->close();
?>
printf("Result set has %d fields.\n", $field_cnt);
]]>
</programlisting>
</example>
@ -74,34 +62,22 @@ $mysqli->close();
<programlisting role="php">
<![CDATA[
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($link, "SELECT Name, CountryCode, District, Population FROM City ORDER BY ID LIMIT 1");
if ($result = mysqli_query($link, "SELECT * FROM City ORDER BY ID LIMIT 1")) {
/* Get the number of fields in the result set */
$field_cnt = mysqli_num_fields($result);
/* determine number of fields in result set */
$field_cnt = mysqli_num_fields($result);
printf("Result set has %d fields.\n", $field_cnt);
/* close result set */
mysqli_free_result($result);
}
/* close connection */
mysqli_close($link);
?>
printf("Result set has %d fields.\n", $field_cnt);
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
Result set has 5 fields.
Result set has 4 fields.
]]>
</screen>
</example>