You are here

function devel_queries in Devel 5

Same name and namespace in other branches
  1. 6 devel.module \devel_queries()
1 string reference to 'devel_queries'
devel_menu in ./devel.module
Implementation of hook_menu().

File

./devel.module, line 1425

Code

function devel_queries() {
  $header = array(
    array(
      'data' => t('Total (ms)'),
      'field' => 'total_time',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Average (ms)'),
      'field' => 'average',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Std deviation (ms)'),
    ),
    array(
      'data' => t('Count'),
      'field' => 'count',
    ),
    array(
      'data' => t('Function'),
      'field' => 'q.function',
    ),
    array(
      'data' => t('Query'),
      'field' => 'q.query',
    ),
  );
  $result = pager_query('SELECT q.qid, q.query, q.function, t.*, COUNT(t.qid) AS count, SUM(t.time) AS total_time, AVG(t.time) AS average, STDDEV(t.time) AS stddev FROM {devel_queries} q INNER JOIN {devel_times} t ON q.qid = t.qid GROUP BY t.qid ' . tablesort_sql($header), 30, 0, 'SELECT COUNT(qid) FROM {devel_queries}');
  while ($log = db_fetch_object($result)) {
    $rows[] = array(
      round($log->total_time * 1000, 3),
      round($log->average * 1000, 3),
      round($log->stddev * 1000, 3),
      $log->count,
      $log->function,
      check_plain($log->query),
    );
  }
  drupal_set_title(check_plain($node->title));
  $output = theme('table', $header, $rows);
  $output .= theme('pager', NULL, 30, 0);
  $output .= l(t('Delete collected query statistics'), 'devel/queries/empty');
  print theme('page', $output, FALSE);
}