reference/mysqli/mysqli/affected-rows.xml
9ed7c3ebf7ab6929d2fd367734a5d72b16cfc128
...
...
@@ -10,20 +10,18 @@
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<para>&style.oop;</para>
13
-
<fieldsynopsis><type>int</type><varname linkend="mysqli.affected-rows">mysqli->affected_rows</varname></fieldsynopsis>
13
+
<fieldsynopsis><type class="union"><type>int</type><type>string</type></type><varname linkend="mysqli.affected-rows">mysqli-&gt;affected_rows</varname></fieldsynopsis>
14
14
<para>&style.procedural;</para>
15
15
<methodsynopsis>
16
-
<type>int</type><methodname>mysqli_affected_rows</methodname>
17
-
<methodparam><type>mysqli</type><parameter>link</parameter></methodparam>
16
+
<type class="union"><type>int</type><type>string</type></type><methodname>mysqli_affected_rows</methodname>
17
+
<methodparam><type>mysqli</type><parameter>mysql</parameter></methodparam>
18
18
</methodsynopsis>
19
19
<para>
20
20
Returns the number of rows affected by the last <literal>INSERT</literal>,
21
21
<literal>UPDATE</literal>, <literal>REPLACE</literal> or
22
22
<literal>DELETE</literal> query.
23
-
</para>
24
-
<para>
25
-
For SELECT statements <function>mysqli_affected_rows</function> works like
26
-
<function>mysqli_num_rows</function>.
23
+
Works like <function>mysqli_num_rows</function> for
24
+
<literal>SELECT</literal> statements.
27
25
</para>
28
26
</refsect1>
29
27
...
...
@@ -40,16 +38,18 @@
40
38
&reftitle.returnvalues;
41
39
<para>
42
40
An integer greater than zero indicates the number of rows affected or
43
-
retrieved.
44
-
Zero indicates that no records were updated for an UPDATE statement, no
45
-
rows matched the <literal>WHERE</literal> clause in the query or that no
46
-
query has yet been executed. -1 indicates that the query returned an
47
-
error.
41
+
retrieved. Zero indicates that no records were updated for an
42
+
<literal>UPDATE</literal> statement, no rows matched the
43
+
<literal>WHERE</literal> clause in the query or that no query has yet been
44
+
executed. <literal>-1</literal> indicates that the query returned an error or
45
+
that <function>mysqli_affected_rows</function> was called for an unbuffered
46
+
<literal>SELECT</literal> query.
48
47
</para>
49
48
<note>
50
49
<para>
51
-
If the number of affected rows is greater than the maximum integer value(<constant> PHP_INT_MAX </constant>), the
52
-
number of affected rows will be returned as a string.
50
+
If the number of affected rows is greater than the maximum int value
51
+
(<constant>PHP_INT_MAX</constant>), the number of affected rows will be
52
+
returned as a string.
53
53
</para>
54
54
</note>
55
55
</refsect1>
...
...
@@ -57,18 +57,14 @@
57
57
<refsect1 role="examples">
58
58
&reftitle.examples;
59
59
<example>
60
-
<title><varname>$mysqli->affected_rows</varname> example</title>
60
+
<title><varname>$mysqli-&gt;affected_rows</varname> example</title>
61
61
<para>&style.oop;</para>
62
62
<programlisting role="php">
63
63
<![CDATA[
64
64
<?php
65
-
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
66
65

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

73
69
/* Insert rows */
74
70
$mysqli->query("CREATE TABLE Language SELECT * from CountryLanguage");
...
...
@@ -88,26 +84,17 @@ printf("Affected rows (DELETE): %d\n", $mysqli->affected_rows);
88
84
$result = $mysqli->query("SELECT CountryCode FROM Language");
89
85
printf("Affected rows (SELECT): %d\n", $mysqli->affected_rows);
90
86

91
-
$result->close();
92
-

93
87
/* Delete table Language */
94
88
$mysqli->query("DROP TABLE Language");
95
-

96
-
/* close connection */
97
-
$mysqli->close();
98
-
?>
99
89
]]>
100
90
</programlisting>
101
91
<para>&style.procedural;</para>
102
92
<programlisting role="php">
103
93
<![CDATA[
104
94
<?php
105
-
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
106
95

107
-
if (!$link) {
108
-
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
109
-
exit();
110
-
}
96
+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
97
+
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
111
98

112
99
/* Insert rows */
113
100
mysqli_query($link, "CREATE TABLE Language SELECT * from CountryLanguage");
...
...
@@ -127,14 +114,8 @@ printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($link));
127
114
$result = mysqli_query($link, "SELECT CountryCode FROM Language");
128
115
printf("Affected rows (SELECT): %d\n", mysqli_affected_rows($link));
129
116

130
-
mysqli_free_result($result);
131
-

132
117
/* Delete table Language */
133
118
mysqli_query($link, "DROP TABLE Language");
134
-

135
-
/* close connection */
136
-
mysqli_close($link);
137
-
?>
138
119
]]>
139
120
</programlisting>
140
121
&examples.outputs;
...
...
@@ -160,7 +141,6 @@ Affected rows (SELECT): 169
160
141
</refsect1>
161
142

162
143
</refentry>
163
-

164
144
<!-- Keep this comment at the end of the file
165
145
Local variables:
166
146
mode: sgml
167
147