function dblog_build_filter_query

7.x dblog.admin.inc dblog_build_filter_query()

Builds a query for database log administration filters based on session.

Return value

array An associative array with keys 'where' and 'args'.

1 call to dblog_build_filter_query()
dblog_overview in drupal/modules/dblog/dblog.admin.inc
Page callback: Displays a listing of database log messages.

File

drupal/modules/dblog/dblog.admin.inc, line 212
Administrative page callbacks for the Database Logging module.

Code

function dblog_build_filter_query() {
  if (empty($_SESSION['dblog_overview_filter'])) {
    return;
  }

  $filters = dblog_filters();

  // Build query
  $where = $args = array();
  foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
    $filter_where = array();
    foreach ($filter as $value) {
      $filter_where[] = $filters[$key]['where'];
      $args[] = $value;
    }
    if (!empty($filter_where)) {
      $where[] = '(' . implode(' OR ', $filter_where) . ')';
    }
  }
  $where = !empty($where) ? implode(' AND ', $where) : '';

  return array(
    'where' => $where,
    'args' => $args,
  );
}