PDO::beginTransaction
(no version information, might be only in CVS)
PDO::beginTransaction --
Initiates a transaction
Descripción
bool
PDO::beginTransaction ( void )
Aviso |
Esta función
es EXPERIMENTAL. Esto significa que el
comportamiento de esta función, el nombre de esta
función y en definitiva TODO lo documentado sobre esta
función, puede cambiar en una futura version de PHP SIN
AVISO. La advertencia queda hecha, y utilizar esta extensión
queda bajo su propia responsabilidad. |
Turns off autocommit mode. While autocommit mode is turned off, changes
made to the database via the PDO object instance are not committed until
you end the transaction by calling either
PDO::commit() or PDO::rollback().
Ejemplos
Ejemplo 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 */ ?>
|
|
Ver también
PDO::commit() |
PDO::rollBack() |