You are here

function drupalforfirebug_devel_query_table in Drupal For Firebug 7.2

Same name and namespace in other branches
  1. 6 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 636

Code

function drupalforfirebug_devel_query_table($queries, $counts) {
  $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) {
    $function = !empty($query['caller']['class']) ? $query['caller']['class'] . '::' : '';
    $function .= $query['caller']['function'];
    $count = isset($counts[$query['query']]) ? $counts[$query['query']] : 0;
    $diff = round($query['time'] * 1000, 2);
    if ($diff > variable_get('devel_execution', 5)) {
      $cell[$i][] = array(
        'data' => $diff,
        'class' => 'marker',
      );
    }
    else {
      $cell[$i][] = $diff;
    }
    $cell[$i][] = $count;
    $cell[$i][] = l($function, "http://{$api}/api/function/{$function}/{$version}");

    // EXPLAIN only valid for select queries.
    // 3 divs for each variation of the query. Last 2 are hidden by default.
    $placeholders = '<div class="dev-placeholders">' . check_plain($query['query']) . "</div>\n";
    $args = '<div class="dev-arguments" style="display: none;"></div>' . "\n";
    $explain = '<div class="dev-explain" style="display: none;"></div>' . "\n";
    $cell[$i][] = array(
      'id' => "devel-query-{$i}",
      'data' => $placeholders . $args . $explain,
    );
    $i++;
    unset($diff, $count, $ops);
  }
  if (variable_get('devel_query_sort', DEVEL_QUERY_SORT_BY_SOURCE)) {
    usort($cell, '_devel_table_sort');
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $cell,
  ));
}