reference/mysqli/mysqli_stmt/num-rows.xml
035c126c0393fe154bac46e2c3c489ebadce48a5
...
...
@@ -3,29 +3,32 @@
3
3
<refentry xml:id="mysqli-stmt.num-rows" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>mysqli_stmt::$num_rows</refname>
6
+
<refname>mysqli_stmt::num_rows</refname>
6
7
<refname>mysqli_stmt_num_rows</refname>
7
-
<refpurpose>Return the number of rows in statements result set</refpurpose>
8
+
<refpurpose>Returns the number of rows fetched from the server</refpurpose>
8
9
</refnamediv>
9
10

10
11
<refsect1 role="description">
11
12
&reftitle.description;
12
13
<para>&style.oop;</para>
13
-
<fieldsynopsis><type>int</type><varname linkend="mysqli-stmt.num-rows">mysqli_stmt->num_rows</varname></fieldsynopsis>
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
+
<modifier>public</modifier> <type class="union"><type>int</type><type>string</type></type><methodname>mysqli_stmt::num_rows</methodname>
17
+
<void/>
18
+
</methodsynopsis>
14
19
<para>&style.procedural;</para>
15
20
<methodsynopsis>
16
-
<type>int</type><methodname>mysqli_stmt_num_rows</methodname>
17
-
<methodparam><type>mysqli_stmt</type><parameter>stmt</parameter></methodparam>
21
+
<type class="union"><type>int</type><type>string</type></type><methodname>mysqli_stmt_num_rows</methodname>
22
+
<methodparam><type>mysqli_stmt</type><parameter>statement</parameter></methodparam>
18
23
</methodsynopsis>
19
24
<para>
20
-
Returns the number of rows in the result set.
21
-
The use of <function>mysqli_stmt_num_rows</function>
22
-
depends on whether or not you used
23
-
<function>mysqli_stmt_store_result</function> to buffer the entire result
24
-
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.
25
28
</para>
26
29
<para>
27
-
If you use <function>mysqli_stmt_store_result</function>,
28
-
<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.
29
32
</para>
30
33
</refsect1>
31
34

...
...
@@ -41,8 +44,11 @@
41
44
<refsect1 role="returnvalues">
42
45
&reftitle.returnvalues;
43
46
<para>
44
-
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.
45
50
</para>
51
+
&mysqli.integer.overflow.as.string.note;
46
52
</refsect1>
47
53

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

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

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

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

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

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

75
-
/* close statement */
76
-
$stmt->close();
77
-
}
78
-

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

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

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

102
-
/* execute query */
103
-
mysqli_stmt_execute($stmt);
104
-

105
-
/* store result */
106
-
mysqli_stmt_store_result($stmt);
107
-

108
-
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
86
+
$stmt = mysqli_prepare($link, $query);
87
+
mysqli_stmt_execute($stmt);
109
88

110
-
/* close statement */
111
-
mysqli_stmt_close($stmt);
112
-
}
89
+
/* store the result in an internal buffer */
90
+
mysqli_stmt_store_result($stmt);
113
91

114
-
/* close connection */
115
-
mysqli_close($link);
116
-
?>
92
+
printf("Number of rows: %d.\n", mysqli_stmt_num_rows($stmt));
117
93
]]>
118
94
</programlisting>
119
95
&examples.outputs;
...
...
@@ -129,15 +105,14 @@ Number of rows: 20.
129
105
&reftitle.seealso;
130
106
<para>
131
107
<simplelist>
108
+
<member><function>mysqli_stmt_store_result</function></member>
132
109
<member><function>mysqli_stmt_affected_rows</function></member>
133
110
<member><function>mysqli_prepare</function></member>
134
-
<member><function>mysqli_stmt_store_result</function></member>
135
111
</simplelist>
136
112
</para>
137
113
</refsect1>
138
114

139
115
</refentry>
140
-

141
116
<!-- Keep this comment at the end of the file
142
117
Local variables:
143
118
mode: sgml
144
119