function devel_querylog_explain in Devel 7
Page callback: Called by the AJAX link in query log.
1 string reference to 'devel_querylog_explain'
- devel_menu in ./
devel.module - Implements hook_menu().
File
- ./
devel.pages.inc, line 52 - Page callbacks for Devel.
Code
function devel_querylog_explain($request_id, $qid) {
if (!is_numeric($request_id)) {
return MENU_ACCESS_DENIED;
}
$path = "temporary://devel_querylog/{$request_id}.txt";
$path = file_stream_wrapper_uri_normalize($path);
$output = t('No explain log found.');
if (file_exists($path)) {
$queries = json_decode(file_get_contents($path));
if ($queries !== FALSE && isset($queries[$qid])) {
$header = $rows = array();
$query = $queries[$qid];
$result = db_query('EXPLAIN ' . $query->query, (array) $query->args)
->fetchAllAssoc('table');
$i = 1;
foreach ($result as $row) {
$row = (array) $row;
if ($i == 1) {
$header = array_keys($row);
}
$rows[] = array_values($row);
$i++;
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
));
}
}
// Print and return nothing thus avoiding page wrapper.
print $output;
$GLOBALS['devel_shutdown'] = FALSE;
}