Sets the data, id and col arguments for a batch delete or update statement and is called directly from the objSQL class.
void obj_batch_data ( mixed data, str id[, str col ] )
<?php
try
{
$trans = $dbh->obj_transaction();
//array key must be a unique field in a row (ie: primary key, part #, mfg product #, etc. )
//array values are the data to update
//the second argument is the column name for the unique field
//the third argument is the column to update
$dbh->obj_batch_data( array( 12345S => 12.00,
12345M => 12.50,
12345L => 12.50,
12345XL => 13.00,
12345XXL => 13.00 ), "stock_id", "price" );
$dbh->obj_table( "products" );
$rs = $dbh->obj_update();
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
}
?>
<?php
try
{
$trans = $dbh->obj_transaction();
//data argument can be an array or comma delimited string
//value(s) 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
}
?>