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 */ $dbh->rollBack();
/* Database connection is now back in autocommit mode */ ?>
|
|
參考
PDO::beginTransaction() |
PDO::commit() |