You are here

function drupalforfirebug_devel_query_table in Drupal For Firebug 6

Same name and namespace in other branches
  1. 7.2 drupalforfirebug.module \drupalforfirebug_devel_query_table()
  2. 7 drupalforfirebug.module \drupalforfirebug_devel_query_table()

Replication of Devel Query Display (but as a table instead of CSS styled div structure) This is done to work with the Firefox extension which has a harder time loading CSS

1 call to drupalforfirebug_devel_query_table()
drupalforfirebug_get_sql_log in ./drupalforfirebug.module
Output Function to Return the Results of the SQL Log

File

./drupalforfirebug.module, line 519

Code

function drupalforfirebug_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][] = $function;
    $pos = strpos($query[0], '*/') + 3;
    $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('table', $header, $cell);
}