Executes a delete statement with minimal SQL markup and is called from the objSQL class.
See also: Batch Delete Operations
mixed obj_delete ( [str table[, str where ]] )
Result resource/object or false on failure.
<?php
try
{
$rs = $dbh->obj_delete( "mytable", "dept='IT'" );
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( "mytable" );
$dbh->obj_where( "dept='IT'" );
$rs = $dbh->obj_delete();
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_insert, obj_paging, obj_query, obj_select, obj_update
<?php
try
{
$trans = $dbh->obj_transaction();
//data argument can be an array or comma delimited string
//value should be a unique field in a row (ie: primary key, part #, mfg product #, etc. )
$data = array( 1234,2345,3456,4567,5678,6789 );
$data = "1234,2345,3456,4567,5678,6789";
//the second argument is the column name for the unique field
$dbh->obj_batch_data( $data, "employee_id" );
$dbh->obj_table( "employees" );
$rs = $dbh->obj_delete();
if ( $dbh->obj_error() )
{
$trans->obj_rollback();
throw new Exception( $dbh->obj_error_message() );
}
$trans->obj_commit();
echo $rs->obj_affected_rows();
}
catch ( Exception $e )
{
//log error and/or redirect user to error page
}
?>
See also: obj_batch_data