PDO::rollBack

(no version information, might be only in CVS)

PDO::rollBack --  Rolls back a transaction

Description

bool PDO::rollBack ( void )

警告

この関数は、 実験的なステータスにあります。これは、この関数の 動作、関数名、ここで書かれていること全てがPHPの将来のバージョンで予告 なく変更される可能性があることを意味します。注意を喚起するとともに自分 のリスクでこの関数を使用して下さい。

When issued against databases that support transactions, PDO::rollBack() rolls back any work in progress and and returns the connection state to autocommit mode.

You must issue PDO::beginTransaction() to set the connection state to manual commit mode before issuing PDO::rollBack() has any effect.

例 1. Roll back a transaction

<?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 */
$sth->rollBack();

/* Database connection is now back in autocommit mode */
?>