You are here

function boost_db_multi_update_set in Boost 6

Update records in the database where IN(...).

NOTE Be aware of the servers max_packet_size variable.

Parameters

$table: The name of the table.

$set_field: field names to be compared to

$set_value: field names to be compared to

$set_placeholders: db_query placeholders; like %d or '%s'

$where_field: field names to be compared to

$where_placeholder: db_query placeholders; like %d or '%s'

$data: array of values you wish to be inserted. If you have 3 fields then the array should be structured like array($field_1_value_A, $field_2_value_A, $field_3_value_A, $field_1_value_B, $field_2_value_B, $field_3_value_B);

Return value

returns db_query() result.

1 call to boost_db_multi_update_set()
boost_cache_kill in ./boost.module
Deletes cached page from file system.

File

./boost.module, line 5576
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_db_multi_update_set($table, $set_field, $set_placeholders, $set_value, $where_field, $where_placeholder, $data) {

  // Get the number of rows that will be inserted
  $rows = count($data);

  // Create what goes in the IN ()
  $in = $where_placeholder;

  // Add the rest of the place holders
  for ($i = 1; $i < $rows; $i++) {
    $in .= ', ' . $where_placeholder;
  }

  // Build the query
  $query = "UPDATE {" . $table . "} SET {$set_field} = {$set_placeholders} WHERE {$where_field} IN ({$in})";

  // Add the set value to the top of the array
  array_unshift($data, $set_value);

  // Run the query
  return db_query($query, $data);
}