Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions library/ZFDebug/Controller/Plugin/Debug/Plugin/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,29 @@ public function getProfile()
# Run explain if enabled, supported adapter and SELECT query
if ($this->_explain && $supportedAdapter) {
$queries .= "</td><td style='color:#7F7F7F;padding-left:2em;' nowrap>";

foreach ($adapter->fetchAll('EXPLAIN '.$profile->getQuery()) as $explain) {
$queries .= "<div style='padding-bottom:0.5em'>";
$explainData = array(
'Type' => $explain['select_type'] . ', ' . $explain['type'],
'Table' => $explain['table'],
'Possible keys' => str_replace(',', ', ', $explain['possible_keys']),
'Key used' => $explain['key'],
);
if ($explain['Extra']) {
$explainData['Extra'] = $explain['Extra'];
}
$explainData['Rows'] = $explain['rows'];

$explainEnd = end($explainData);
foreach ($explainData as $key => $value) {
$queries .= "$key: <span style='color:#ffb13e'>$value</span><br>\n";
$queries .= "</td></tr><tr style='color:#7F7F7F;padding-left:2em;' nowrap><td></td><td>"; // better layout
$q = $profile->getQuery();
if ($q !== 'connect') { // can't explain 'connect'
foreach ($adapter->fetchAll('EXPLAIN '.$profile->getQuery()) as $explain) {
$explain = (array)$explain; // in case is a object
$queries .= "<div style='padding-bottom:0.5em'>";
$explainData = array(
'Type' => $explain['select_type'] . ', ' . $explain['type'],
'Table' => $explain['table'],
'Possible keys' => str_replace(',', ', ', $explain['possible_keys']),
'Key used' => $explain['key'],
);
if ($explain['Extra']) {
$explainData['Extra'] = $explain['Extra'];
}
$explainData['Rows'] = $explain['rows'];

$explainEnd = end($explainData);
foreach ($explainData as $key => $value) {
$queries .= "$key: <span style='color:#ffb13e'>$value</span><br>\n";
}
$queries .= "</div>";
}
$queries .= "</div>";
}
}

Expand All @@ -198,4 +202,4 @@ protected function _addQuotes(&$value, $key)
{
$value = "'" . $value . "'";
}
}
}