Project Pages

objSQL Home
Freshmeat
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_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_savepoint
obj_transaction

Utility Methods

obj_escape
obj_info
obj_row_count


obj_fetch_object

Description:

Returns a resultset as an object.

  • The fields ( column names ) are case-sensitive.
  • Firebird and Oracle require the named field object returned in all uppercase.

Parameters:

mixed obj_fetch_object ( void )


Returns:

Object or null if no more rows.


Example:

<?php 

try 

    
$rs $dbh->obj_select"mytable""color,size,price""product='balloons'""price" ); 
     
    if ( 
$dbh->obj_error() ) 
        throw new 
Exception$dbh->obj_error_message() ); 
         
    while ( 
$obj $rs->obj_fetch_object() )  
    { 
        
printf "%s %s %s \n"$obj->color,  
                                
$obj->size,  
                                
$obj->price ); 
    } 
     
    echo 
$rs->obj_num_rows(); 
     
    
$rs->obj_free_result(); 

catch ( 
Exception $e )  

    
//log error and/or redirect user to error page 
}  

//Firebird and Oracle

try 

    
$rs $dbh->obj_select"mytable""color,size,price""product='balloons'""price" ); 
     
    if ( 
$dbh->obj_error() ) 
        throw new 
Exception$dbh->obj_error_message() ); 
         
    while ( 
$obj $rs->obj_fetch_object() )  
    { 
        
printf "%s %s %s \n"$obj->COLOR,  
                                
$obj->SIZE,  
                                
$obj->PRICE ); 
    } 
     
    echo 
$rs->obj_num_rows(); 
     
    
$rs->obj_free_result(); 

catch ( 
Exception $e )  

    
//log error and/or redirect user to error page 
}  

?>

See also: obj_fetch_assoc, obj_fetch_num