reference/mysqli/mysqli_stmt/num-rows.xml
035c126c0393fe154bac46e2c3c489ebadce48a5
...
...
@@ -5,32 +5,30 @@
5
5
<refname>mysqli_stmt::$num_rows</refname>
6
6
<refname>mysqli_stmt::num_rows</refname>
7
7
<refname>mysqli_stmt_num_rows</refname>
8
-
<refpurpose>Return the number of rows in statements result set</refpurpose>
8
+
<refpurpose>Returns the number of rows fetched from the server</refpurpose>
9
9
</refnamediv>
10
10

11
11
<refsect1 role="description">
12
12
&reftitle.description;
13
13
<para>&style.oop;</para>
14
-
<fieldsynopsis><type>int</type><varname linkend="mysqli-stmt.num-rows">mysqli_stmt-&gt;num_rows</varname></fieldsynopsis>
15
-
<methodsynopsis role="oop">
14
+
<fieldsynopsis><type class="union"><type>int</type><type>string</type></type><varname linkend="mysqli-stmt.num-rows">mysqli_stmt-&gt;num_rows</varname></fieldsynopsis>
15
+
<methodsynopsis role="mysqli_stmt">
16
16
<modifier>public</modifier> <type class="union"><type>int</type><type>string</type></type><methodname>mysqli_stmt::num_rows</methodname>
17
17
<void/>
18
18
</methodsynopsis>
19
19
<para>&style.procedural;</para>
20
-
<methodsynopsis role="procedural">
20
+
<methodsynopsis>
21
21
<type class="union"><type>int</type><type>string</type></type><methodname>mysqli_stmt_num_rows</methodname>
22
22
<methodparam><type>mysqli_stmt</type><parameter>statement</parameter></methodparam>
23
23
</methodsynopsis>
24
24
<para>
25
-
Returns the number of rows in the result set.
26
-
The use of <function>mysqli_stmt_num_rows</function>
27
-
depends on whether or not you used
28
-
<function>mysqli_stmt_store_result</function> to buffer the entire result
29
-
set in the statement handle.
25
+
Returns the number of rows buffered in the statement. This function will only
26
+
work after <function>mysqli_stmt_store_result</function> is called to buffer
27
+
the entire result set in the statement handle.
30
28
</para>
31
29
<para>
32
-
If you use <function>mysqli_stmt_store_result</function>,
33
-
<function>mysqli_stmt_num_rows</function> may be called immediately.
30
+
This function returns <literal>0</literal> unless all rows have been
31
+
fetched from the server.
34
32
</para>
35
33
</refsect1>
36
34

...
...
@@ -46,8 +44,11 @@
46
44
<refsect1 role="returnvalues">
47
45
&reftitle.returnvalues;
48
46
<para>
49
-
An integer representing the number of rows in result set.
47
+
An &integer; representing the number of buffered rows.
48
+
Returns <literal>0</literal> in unbuffered mode unless all rows have been
49
+
fetched from the server.
50
50
</para>
51
+
&mysqli.integer.overflow.as.string.note;
51
52
</refsect1>
52
53

53
54
<refsect1 role="examples">
...
...
@@ -57,33 +58,18 @@
57
58
<programlisting role="php">
58
59
<![CDATA[
59
60
<?php
60
-
/* Open a connection */
61
-
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
62
61

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

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

72
-
/* execute query */
73
-
$stmt->execute();
66
+
$stmt = $mysqli->prepare($query);
67
+
$stmt->execute();
74
68

75
-
/* store result */
76
-
$stmt->store_result();
69
+
/* store the result in an internal buffer */
70
+
$stmt->store_result();
77
71

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

80
-
/* close statement */
81
-
$stmt->close();
82
-
}
83
-

84
-
/* close connection */
85
-
$mysqli->close();
86
-
?>
72
+
printf("Number of rows: %d.\n", $stmt->num_rows);
87
73
]]>
88
74
</programlisting>
89
75
</example>
...
...
@@ -92,33 +78,18 @@ $mysqli->close();
92
78
<programlisting role="php">
93
79
<![CDATA[
94
80
<?php
95
-
/* Open a connection */
96
-
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
97
81

98
-
/* check connection */
99
-
if (mysqli_connect_errno()) {
100
-
printf("Connect failed: %s\n", mysqli_connect_error());
101
-
exit();
102
-
}
82
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
83
+
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
103
84

104
85
$query = "SELECT Name, CountryCode FROM City ORDER BY Name LIMIT 20";
105
-
if ($stmt = mysqli_prepare($link, $query)) {
106
-

107
-
/* execute query */
108
-
mysqli_stmt_execute($stmt);
109
-

110
-
/* store result */
111
-
mysqli_stmt_store_result($stmt);
86
+
$stmt = mysqli_prepare($link, $query);
87
+
mysqli_stmt_execute($stmt);
112
88

113
-
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
89
+
/* store the result in an internal buffer */
90
+
mysqli_stmt_store_result($stmt);
114
91

115
-
/* close statement */
116
-
mysqli_stmt_close($stmt);
117
-
}
118
-

119
-
/* close connection */
120
-
mysqli_close($link);
121
-
?>
92
+
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
122
93
]]>
123
94
</programlisting>
124
95
&examples.outputs;
...
...
@@ -134,9 +105,9 @@ Number of rows: 20.
134
105
&reftitle.seealso;
135
106
<para>
136
107
<simplelist>
108
+
<member><function>mysqli_stmt_store_result</function></member>
137
109
<member><function>mysqli_stmt_affected_rows</function></member>
138
110
<member><function>mysqli_prepare</function></member>
139
-
<member><function>mysqli_stmt_store_result</function></member>
140
111
</simplelist>
141
112
</para>
142
113
</refsect1>
143
114