You are here

function devel_query_table in Devel 5

Same name and namespace in other branches
  1. 6 devel.module \devel_query_table()
  2. 7 devel.module \devel_query_table()

Adds a table at the bottom of the page cataloguing data on all the database queries that were made to generate the page.

1 call to devel_query_table()
devel_shutdown in ./devel.module
See devel_init() which registers this function as a shutdown function. Displays developer information in the footer.

File

./devel.module, line 1183

Code

function devel_query_table($queries, $counts) {
  $header = array(
    'ms',
    '#',
    'where',
    'query',
  );
  $i = 0;
  foreach ($queries as $query) {
    $ar = explode("\n", $query[0]);
    $function = array_shift($ar);
    $count = isset($counts[$query[0]]) ? $counts[$query[0]] : 0;
    $query[0] = join(' ', $ar);
    $diff = round($query[1] * 1000, 2);
    if ($diff > variable_get('devel_execution', 5)) {
      $cell[$i][] = array(
        'data' => $diff,
        'class' => 'marker',
      );
    }
    else {
      $cell[$i][] = $diff;
    }
    if ($count > 1) {
      $cell[$i][] = array(
        'data' => $count,
        'class' => 'marker',
      );
    }
    else {
      $cell[$i][] = $count;
    }
    $cell[$i][] = l($function, "http://api.drupal.org/api/HEAD/function/{$function}");
    $cell[$i][] = check_plain($query[0]);
    $i++;
    unset($diff, $count);
  }
  if (variable_get('devel_query_sort', DEVEL_QUERY_SORT_BY_SOURCE)) {
    usort($cell, '_devel_table_sort');
  }
  return theme('table', $header, $cell);
}