Project Pages

PHP Classes
SourceForge
Downloads
Archived Documentation

DB Connection Methods

objSQL
obj_close

Error Handling Methods

obj_error
obj_error_message

Statement Methods

obj_delete
obj_insert
obj_paging
obj_query
obj_select
obj_update

Resultset Methods

obj_affected_rows
obj_fetch_assoc
obj_fetch_num
obj_fetch_object
obj_field
obj_free_result
obj_num_fields
obj_num_rows

Prepared Statement Methods

obj_bind
obj_close_statement
obj_execute
obj_free_statement
obj_prepare_statement

Transaction Methods

obj_commit
obj_rollback
obj_transaction

Utility Methods

obj_escape
obj_info
obj_row_count


obj_savepoint

Description:

Sets a savepoint within a transaction block.

Savepoints allow you set a point within a transaction to rollback to if a failed condition is met without affecting any work done in the transaction before the savepoint was declared.

  • The name argument is required.

Parameters:

bool obj_savepoint ( str name )


Returns:

True on success or false on failure.


Examples:

<?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_rollback, obj_savepoint