'; foreach ($_SESSION['debug'] as $q => $qq) { // Fix the indentation.... $qq['q'] = ltrim(str_replace("\r", '', $qq['q']), "\n"); $query = explode("\n", $qq['q']); $min_indent = 0; foreach ($query as $line) { preg_match('/^(\t*)/', $line, $qqi); if (strlen($qqi[0]) < $min_indent || $min_indent == 0) $min_indent = strlen($qqi[0]); } foreach ($query as $l => $dummy) $query[$l] = substr($dummy, $min_indent); $qq['q'] = implode("\n", $query); $is_select_query = substr(trim($qq['q']), 0, 6) == 'SELECT'; echo ' ' . nl2br(str_replace("\t", '   ', htmlspecialchars($qq['q']))) . '
in ' . $qq['f'] . ' line ' . $qq['l'] . ', which took ' . $qq['t'] . ' seconds.

'; // Explain the query. if ($qqj == $q + 1 && $is_select_query) { $result = mysql_query(" EXPLAIN " . $qq['q'], $db_connection); if ($result === false) die(mysql_error($db_connection)); echo ' '; $row = mysql_fetch_assoc($result); mysql_data_seek($result, 0); echo ' '; while ($row = mysql_fetch_assoc($result)) { echo ' '; } echo '
' . implode(' ', array_keys($row)) . '
' . implode(' ', $row) . '

'; } } echo ' '; obExit(false); } ?>