You are here

function devel_query_table in Devel 6

Same name and namespace in other branches
  1. 5 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_real in ./devel.module
See devel_shutdown() which registers this function as a shutdown function. Displays developer information in the footer.

File

./devel.module, line 1682

Code

function devel_query_table($queries, $counts) {
  if (empty($queries)) {
    return FALSE;
  }
  $version = devel_get_core_version(VERSION);
  $header = array(
    'ms',
    '#',
    'where',
    'query',
  );
  $i = 0;
  $api = variable_get('devel_api_url', 'api.drupal.org');
  foreach ($queries as $query) {

    // dprint_r($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}/api/{$version}/function/{$function}");
    $pos = strpos($query[0], '*/') !== FALSE ? strpos($query[0], '*/') + 3 : 0;
    $cell[$i][] = check_plain(substr($query[0], $pos));
    $i++;
    unset($diff, $count);
  }
  if (variable_get('devel_query_sort', DEVEL_QUERY_SORT_BY_SOURCE)) {
    usort($cell, '_devel_table_sort');
  }
  return theme('devel_querylog', $header, $cell);
}