Rolls back a transaction block.
When errors occur, obj_rollback allows you to void any transactional queries within a transaction block.
bool obj_rollback ( str [ name ] )
True on success or false on failure.
<?php
try
{
$trans = $dbh->obj_transaction();
$data = array( "color" => "blue",
"type" => "leather",
"price" => 36.95 );
$rs = $dbh->obj_update( "products", $data, "prod_id=21" );
if ( $dbh->obj_error() )
{
$trans->obj_rollback();
throw new Exception( $dbh->obj_error_message() );
}
$trans->obj_savepoint( "svp1" );
$data = array( "color" => "red",
"type" => "leather",
"price" => 32.95 );
$rs = $dbh->obj_update( "products", $data, "prod_id=49" );
if ( $dbh->obj_error() )
{
$trans->obj_rollback( "svp1" );
$trans->obj_commit();
throw new Exception( $dbh->obj_error_message() );
}
else
$trans->obj_commit();
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
?>
See also: obj_commit, obj_savepoint