You are here

function customfilter_get_sets in Custom filter 5

Get filter sets from database.

Parameters

$cols: Columns to be retrieved.

$cond: Condition, return all results by default.

Return value

Array of filter sets.

4 calls to customfilter_get_sets()
customfilter_export_form in ./customfilter.module
Export form.
customfilter_help in ./customfilter.module
Implements hook_help().
customfilter_set_get_rows in ./customfilter.module
_customfilter_filter_list in ./customfilter.module

File

./customfilter.module, line 1010

Code

function customfilter_get_sets($cols = array(
  'sid',
  'name',
  'description',
), $cond = '1=1') {
  static $sets;
  if (!isset($sets)) {
    $sets = array();

    // Prepare columns to select
    if (!is_array($cols)) {
      $cols = array(
        $cols,
      );
    }
    $columns = join(', ', $cols);

    // Query & fetch
    $result = db_query("SELECT {$columns} FROM {customfilter_set} WHERE {$cond} ORDER BY name");
    while ($set = db_fetch_array($result)) {
      $sets[] = $set;
    }
  }
  return $sets;
}