2004-11-10 22:21:24 +00:00
|
|
|
<?xml version='1.0' encoding='iso-8859-1'?>
|
2005-09-11 06:22:26 +00:00
|
|
|
<!-- $Revision: 1.7 $ -->
|
2004-11-10 22:21:24 +00:00
|
|
|
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
|
|
|
|
<refentry id="function.PDO-rollBack">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>PDO::rollBack</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Rolls back a transaction
|
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
2005-02-05 18:52:58 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2004-11-10 22:21:24 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>bool</type><methodname>PDO::rollBack</methodname>
|
|
|
|
<void/>
|
|
|
|
</methodsynopsis>
|
|
|
|
|
|
|
|
<para>
|
2005-07-11 04:38:55 +00:00
|
|
|
Rolls back the current transaction, as initiated by
|
|
|
|
<function>PDO::beginTransaction</function>. It is an error to call this
|
|
|
|
method if no transaction is active.
|
2004-11-10 22:21:24 +00:00
|
|
|
</para>
|
2004-11-19 15:55:49 +00:00
|
|
|
<para>
|
2005-07-11 04:38:55 +00:00
|
|
|
If the database was set to autocommit mode, this function will restore
|
|
|
|
autocommit mode after it has rolled back the transaction.
|
2004-11-19 15:55:49 +00:00
|
|
|
</para>
|
2005-08-24 11:07:45 +00:00
|
|
|
<para>
|
|
|
|
Some databases, including MySQL, automatically issue an implicit
|
|
|
|
COMMIT when a database definition language (DDL) statement such as
|
|
|
|
DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
|
|
|
|
COMMIT will prevent you from rolling back any other changes within the
|
|
|
|
transaction boundary.
|
|
|
|
</para>
|
2005-02-05 18:52:58 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
<example><title>Roll back a transaction</title>
|
2005-08-24 11:07:45 +00:00
|
|
|
<para>
|
|
|
|
The following example begins a transaction and issues two statements
|
|
|
|
that modify the database before rolling back the changes. On MySQL,
|
|
|
|
however, the DROP TABLE statement automatically commits the
|
|
|
|
transaction so that none of the changes in the transaction are rolled
|
|
|
|
back.
|
|
|
|
</para>
|
2005-02-05 18:52:58 +00:00
|
|
|
<programlisting role='php'>
|
2004-11-19 15:55:49 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
/* Begin a transaction, turning off autocommit */
|
|
|
|
$dbh->beginTransaction();
|
|
|
|
|
|
|
|
/* Change the database schema and data */
|
|
|
|
$sth = $dbh->exec("DROP TABLE fruit");
|
|
|
|
$sth = $dbh->exec("UPDATE dessert
|
|
|
|
SET name = 'hamburger'");
|
|
|
|
|
|
|
|
/* Recognize mistake and roll back changes */
|
2005-02-05 18:52:58 +00:00
|
|
|
$dbh->rollBack();
|
2004-11-19 15:55:49 +00:00
|
|
|
|
|
|
|
/* Database connection is now back in autocommit mode */
|
|
|
|
?>
|
|
|
|
]]>
|
2005-02-05 18:52:58 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2004-11-10 22:21:24 +00:00
|
|
|
|
2005-02-05 18:52:58 +00:00
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
|
|
|
<para>
|
|
|
|
<simplelist>
|
|
|
|
<member><function>PDO::beginTransaction</function></member>
|
|
|
|
<member><function>PDO::commit</function></member>
|
|
|
|
</simplelist>
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</refsect1>
|
2005-02-05 18:52:58 +00:00
|
|
|
|
|
|
|
|
2004-11-10 22:21:24 +00:00
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|