Executes an update statement with minimal SQL markup and is called from the objSQL class.
mixed obj_update ( [str table, [array data[, str where ]]] )
Result resource/object or false on failure.
<?php
try
{
$data = array( "color" => "blue",
"type" => "leather",
"price" => 36.95 );
$rs = $dbh->obj_update( "products", $data, "prod_id=21" );
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
echo $rs->obj_affected_rows();
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
try
{
//set arguments using statement argument helper methods
$dbh->obj_table( "products" );
$dbh->obj_data( array( "color" => "blue", "type" => "leather", "price" => 36.95 ) );
$dbh->obj_where( "prod_id=21" );
$rs = $dbh->obj_update();
if ( $dbh->obj_error() )
throw new Exception( $dbh->obj_error_message() );
echo $rs->obj_affected_rows();
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
?>
See also: obj_delete, obj_insert, obj_paging, obj_query, obj_select