DB_common::rollback()
DB_common::rollback() – Rolls back the current transaction
Synopsis
mixed rollback (
)
Описание
Rolls back the current transaction.
Throws
Error code | Error message | Reason | Solution |
---|---|---|---|
every other error code | Database specific error | Check the database related section of PHP-Руководство to detect the reason for this error. |
Замечание
This function can not be called statically.
When using MySQL as your DBMS, transactions can only be used when the tables in question use the InnoDB format.
Пример
Using rollback()
<?php
// Once you have a valid DB object named $db...
$db->autoCommit(false);
$db->query('INSERT INTO blah (a) VALUES (11)');
$res =& $db->query('SELECT b FROM blue');
if (DB::isError($res)) {
echo $res->getMessage() . "\n";
}
while ($res->fetchInto($row, DB_FETCHMODE_ORDERED)) {
if ($row[0] == 'problem') {
$db->rollback();
}
}
$res->free();
$db->query('DROP TABLE blah');
$db->commit();
?>