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

NOTE Be aware of the servers max_packet_size variable.

Paramètres

$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 dans ./advagg.module
Given a list of files; return back the aggregated filename.

Fichier

./advagg.module, line 3180

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);
}