PDO::beginTransaction

(no version information, might be only in CVS)

PDO::beginTransaction --  Initiates a transaction

Descrição

bool PDO::beginTransaction ( void )

Atenção

Esta função é EXPERIMENTAL. Isso quer dizer que o comportamento desta função e seu nome, incluindo TUDO o que está documentado aqui pode mudar em futuras versões do PHP, SEM QUALQUER NOTIFICAÇÃO. Esteja avisado, e use esta função por sua própria conta e risco.

Turns off autocommit mode. Call PDO::commit() or PDO::rollback() to end the transaction and return to autocommit mode.

Exemplos

Exemplo 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 */
?>

Veja também

PDO::commit()
PDO::rollBack()