You are here

function advagg_db_multi_select_in in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 6 advagg.module \advagg_db_multi_select_in()

Select records in the database matching where IN(...).

NOTE Be aware of the servers max_packet_size variable.

Parameters

$table: The name of the table.

$field: field name to be compared to

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

$data: array of values you wish to compare to

$returns: array of db fields you return

Return value

returns db_query() result.

1 call to advagg_db_multi_select_in()
advagg_get_filename in ./advagg.module
Given a list of files; return back the aggregated filename.

File

./advagg.module, line 3180
Advanced CSS/JS aggregation module

Code

function advagg_db_multi_select_in($table, $field, $placeholder, $data, $returns = array(), $groupby = '') {

  // Set returns if empty
  if (empty($returns)) {
    $returns[] = '*';
  }

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

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

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

  // Build the query
  $query = "SELECT " . implode(', ', $returns) . " FROM {" . $table . "} WHERE {$field} IN ({$in}) {$groupby}";

  // Run the query
  // TODO Please convert this statement to the D7 database API syntax.
  return db_query($query, $data);
}