reference/mysqli/mysqli_result/field-count.xml
a3051835f7095013fb9760e6d06d190f584fc609
...
...
@@ -4,7 +4,7 @@
4
4
<refnamediv>
5
5
<refname>mysqli_result::$field_count</refname>
6
6
<refname>mysqli_num_fields</refname>
7
-
<refpurpose>Get the number of fields in a result</refpurpose>
7
+
<refpurpose>Gets the number of fields in the result set</refpurpose>
8
8
</refnamediv>
9
9

10
10
<refsect1 role="description">
...
...
@@ -17,7 +17,7 @@
17
17
<methodparam><type>mysqli_result</type><parameter>result</parameter></methodparam>
18
18
</methodsynopsis>
19
19
<para>
20
-
Returns the number of fields from specified result set.
20
+
Returns the number of fields in the result set.
21
21
</para>
22
22
</refsect1>
23
23

...
...
@@ -33,7 +33,7 @@
33
33
<refsect1 role="returnvalues">
34
34
&reftitle.returnvalues;
35
35
<para>
36
-
The number of fields from a result set.
36
+
An <type>int</type> representing the number of fields.
37
37
</para>
38
38
</refsect1>
39
39

...
...
@@ -44,28 +44,16 @@
44
44
<programlisting role="php">
45
45
<![CDATA[
46
46
<?php
47
-
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
48
-

49
-
/* check connection */
50
-
if (mysqli_connect_errno()) {
51
-
printf("Connect failed: %s\n", mysqli_connect_error());
52
-
exit();
53
-
}
54
47

55
-
if ($result = $mysqli->query("SELECT * FROM City ORDER BY ID LIMIT 1")) {
56
-

57
-
/* determine number of fields in result set */
58
-
$field_cnt = $result->field_count;
48
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
49
+
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
59
50

60
-
printf("Result set has %d fields.\n", $field_cnt);
51
+
$result = $mysqli->query("SELECT Name, CountryCode, District, Population FROM City ORDER BY ID LIMIT 1");
61
52

62
-
/* close result set */
63
-
$result->close();
64
-
}
53
+
/* Get the number of fields in the result set */
54
+
$field_cnt = $result->field_count;
65
55

66
-
/* close connection */
67
-
$mysqli->close();
68
-
?>
56
+
printf("Result set has %d fields.\n", $field_cnt);
69
57
]]>
70
58
</programlisting>
71
59
</example>
...
...
@@ -74,34 +62,22 @@ $mysqli->close();
74
62
<programlisting role="php">
75
63
<![CDATA[
76
64
<?php
77
-
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
78
-

79
-
/* check connection */
80
-
if (mysqli_connect_errno()) {
81
-
printf("Connect failed: %s\n", mysqli_connect_error());
82
-
exit();
83
-
}
84
65

85
-
if ($result = mysqli_query($link, "SELECT * FROM City ORDER BY ID LIMIT 1")) {
86
-

87
-
/* determine number of fields in result set */
88
-
$field_cnt = mysqli_num_fields($result);
66
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
67
+
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
89
68

90
-
printf("Result set has %d fields.\n", $field_cnt);
69
+
$result = mysqli_query($link, "SELECT Name, CountryCode, District, Population FROM City ORDER BY ID LIMIT 1");
91
70

92
-
/* close result set */
93
-
mysqli_free_result($result);
94
-
}
71
+
/* Get the number of fields in the result set */
72
+
$field_cnt = mysqli_num_fields($result);
95
73

96
-
/* close connection */
97
-
mysqli_close($link);
98
-
?>
74
+
printf("Result set has %d fields.\n", $field_cnt);
99
75
]]>
100
76
</programlisting>
101
77
&examples.outputs;
102
78
<screen>
103
79
<![CDATA[
104
-
Result set has 5 fields.
80
+
Result set has 4 fields.
105
81
]]>
106
82
</screen>
107
83
</example>
108
84