Executes a select statement with minimal SQL markup and is called from the objSQL class.
mixed obj_select ( [str table[, str cols[, str where[, str order by[, str sort order ]]]]] )
Result resource/object or false on failure.
<?php
try
{
$rs = $dbh->obj_select( "mytable","color,size,price","product='balloons'","price" );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
echo $rs->obj_num_rows();
$rs->obj_free_result();
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
try
{
//set arguments using statement argument helper methods
$dbh->obj_table( "mytable" );
$dbh->obj_cols( "color,size,price" );
$dbh->obj_where( "product='balloons'" );
$dbh->obj_order_by( "price" );
$dbh->obj_sort_order( "asc" );
$rs = $dbh->obj_select();
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 );
}
$rs->obj_free_result();
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
?>
See also: obj_delete, obj_insert, obj_paging, obj_query, obj_update