reference/mysqli/mysqli/rollback.xml
63b99082ef83eade08151f8cb528246fded81db9
...
...
@@ -10,14 +10,17 @@
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<para>&style.oop;</para>
13
-
<methodsynopsis role="oop">
14
-
<type>bool</type><methodname>mysqli::rollback</methodname>
15
-
<void/>
13
+
<methodsynopsis role="mysqli">
14
+
<modifier>public</modifier> <type>bool</type><methodname>mysqli::rollback</methodname>
15
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>name</parameter><initializer>&null;</initializer></methodparam>
16
17
</methodsynopsis>
17
18
<para>&style.procedural;</para>
18
19
<methodsynopsis>
19
20
<type>bool</type><methodname>mysqli_rollback</methodname>
20
-
<methodparam><type>mysqli</type><parameter>link</parameter></methodparam>
21
+
<methodparam><type>mysqli</type><parameter>mysql</parameter></methodparam>
22
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
23
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>name</parameter><initializer>&null;</initializer></methodparam>
21
24
</methodsynopsis>
22
25
<para>
23
26
Rollbacks the current transaction for the database.
...
...
@@ -29,6 +32,22 @@
29
32
<para>
30
33
<variablelist>
31
34
&mysqli.link.description;
35
+
<varlistentry>
36
+
<term><parameter>flags</parameter></term>
37
+
<listitem>
38
+
<para>
39
+
A bitmask of <constant>MYSQLI_TRANS_COR_*</constant> constants.
40
+
</para>
41
+
</listitem>
42
+
</varlistentry>
43
+
<varlistentry>
44
+
<term><parameter>name</parameter></term>
45
+
<listitem>
46
+
<para>
47
+
If provided then <literal>ROLLBACK/*name*/</literal> is executed.
48
+
</para>
49
+
</listitem>
50
+
</varlistentry>
32
51
</variablelist>
33
52
</para>
34
53
</refsect1>
...
...
@@ -40,130 +59,65 @@
40
59
</para>
41
60
</refsect1>
42
61

43
-
<refsect1 role="examples">
44
-
&reftitle.examples;
45
-
<example>
46
-
<title><methodname>mysqli::rollback</methodname> example</title>
47
-
<para>&style.oop;</para>
48
-
<programlisting role="php">
49
-
<![CDATA[
50
-
<?php
51
-
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
52
-

53
-
/* check connection */
54
-
if (mysqli_connect_errno()) {
55
-
printf("Connect failed: %s\n", mysqli_connect_error());
56
-
exit();
57
-
}
58
-

59
-
/* disable autocommit */
60
-
$mysqli->autocommit(FALSE);
61
-

62
-
$mysqli->query("CREATE TABLE myCity LIKE City");
63
-
$mysqli->query("ALTER TABLE myCity Type=InnoDB");
64
-
$mysqli->query("INSERT INTO myCity SELECT * FROM City LIMIT 50");
65
-

66
-
/* commit insert */
67
-
$mysqli->commit();
68
-

69
-
/* delete all rows */
70
-
$mysqli->query("DELETE FROM myCity");
71
-

72
-
if ($result = $mysqli->query("SELECT COUNT(*) FROM myCity")) {
73
-
$row = $result->fetch_row();
74
-
printf("%d rows in table myCity.\n", $row[0]);
75
-
/* Free result */
76
-
$result->close();
77
-
}
78
-

79
-
/* Rollback */
80
-
$mysqli->rollback();
81
-

82
-
if ($result = $mysqli->query("SELECT COUNT(*) FROM myCity")) {
83
-
$row = $result->fetch_row();
84
-
printf("%d rows in table myCity (after rollback).\n", $row[0]);
85
-
/* Free result */
86
-
$result->close();
87
-
}
88
-

89
-
/* Drop table myCity */
90
-
$mysqli->query("DROP TABLE myCity");
91
-

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

102
-
/* check connection */
103
-
if (mysqli_connect_errno()) {
104
-
printf("Connect failed: %s\n", mysqli_connect_error());
105
-
exit();
106
-
}
107
-

108
-
/* disable autocommit */
109
-
mysqli_autocommit($link, FALSE);
110
-

111
-
mysqli_query($link, "CREATE TABLE myCity LIKE City");
112
-
mysqli_query($link, "ALTER TABLE myCity Type=InnoDB");
113
-
mysqli_query($link, "INSERT INTO myCity SELECT * FROM City LIMIT 50");
114
-

115
-
/* commit insert */
116
-
mysqli_commit($link);
117
-

118
-
/* delete all rows */
119
-
mysqli_query($link, "DELETE FROM myCity");
120
-

121
-
if ($result = mysqli_query($link, "SELECT COUNT(*) FROM myCity")) {
122
-
$row = mysqli_fetch_row($result);
123
-
printf("%d rows in table myCity.\n", $row[0]);
124
-
/* Free result */
125
-
mysqli_free_result($result);
126
-
}
127
-

128
-
/* Rollback */
129
-
mysqli_rollback($link);
62
+
<refsect1 role="errors">
63
+
&reftitle.errors;
64
+
&mysqli.conditionalexception;
65
+
</refsect1>
130
66

131
-
if ($result = mysqli_query($link, "SELECT COUNT(*) FROM myCity")) {
132
-
$row = mysqli_fetch_row($result);
133
-
printf("%d rows in table myCity (after rollback).\n", $row[0]);
134
-
/* Free result */
135
-
mysqli_free_result($result);
136
-
}
67
+
<refsect1 role="changelog">
68
+
&reftitle.changelog;
69
+
<para>
70
+
<informaltable>
71
+
<tgroup cols="2">
72
+
<thead>
73
+
<row>
74
+
<entry>&Version;</entry>
75
+
<entry>&Description;</entry>
76
+
</row>
77
+
</thead>
78
+
<tbody>
79
+
<row>
80
+
<entry>8.0.0</entry>
81
+
<entry>
82
+
<parameter>name</parameter> is now nullable.
83
+
</entry>
84
+
</row>
85
+
</tbody>
86
+
</tgroup>
87
+
</informaltable>
88
+
</para>
89
+
</refsect1>
137
90

138
-
/* Drop table myCity */
139
-
mysqli_query($link, "DROP TABLE myCity");
91
+
<refsect1 role="examples">
92
+
&reftitle.examples;
93
+
<para>
94
+
See the <link linkend="mysqli.begin-transaction.example.basic"><methodname>mysqli::begin_transaction</methodname> example</link>.
95
+
</para>
96
+
</refsect1>
140
97

141
-
mysqli_close($link);
142
-
?>
143
-
]]>
144
-
</programlisting>
145
-
&examples.outputs;
146
-
<screen>
147
-
<![CDATA[
148
-
0 rows in table myCity.
149
-
50 rows in table myCity (after rollback).
150
-
]]>
151
-
</screen>
152
-
</example>
98
+
<refsect1 role="notes">
99
+
&reftitle.notes;
100
+
<note>
101
+
<para>
102
+
This function does not work with non transactional table types (like
103
+
MyISAM or ISAM).
104
+
</para>
105
+
</note>
153
106
</refsect1>
154
107

155
108
<refsect1 role="seealso">
156
109
&reftitle.seealso;
157
110
<para>
158
111
<simplelist>
112
+
<member><function>mysqli_begin_transaction</function></member>
159
113
<member><function>mysqli_commit</function></member>
160
114
<member><function>mysqli_autocommit</function></member>
115
+
<member><function>mysqli_release_savepoint</function></member>
161
116
</simplelist>
162
117
</para>
163
118
</refsect1>
164
119

165
120
</refentry>
166
-

167
121
<!-- Keep this comment at the end of the file
168
122
Local variables:
169
123
mode: sgml
170
124