Skip to content

Instantly share code, notes, and snippets.

@bjyoungblood
Created September 15, 2012 00:12
Show Gist options
  • Save bjyoungblood/3725712 to your computer and use it in GitHub Desktop.
Save bjyoungblood/3725712 to your computer and use it in GitHub Desktop.
db-profile-partial
<div class="portlet x12">
<div class="portlet-header">
<h4>All Database Queries</h4>
</div>
<div class="portlet-content">
<table width="100%">
<tr><th></th><th>Query</th><th>Type</th><th>Time</th></tr>
<?php foreach ($this->dbQueryProfiles() as $index => $p) : ?>
<?php $profile = $p->toArray(); ?>
<tr>
<td><a href="javascript:sqlDetail(<?=$index?>)">[+/-]</a></td>
<td><?=$profile['type']?></td>
<td><?=$profile['sql']?></td>
<td><?=$profile['elapsed']?></td>
</tr>
<tr id="sqlDetail-<?=$index?>" style="display:none;">
<td colspan='4'>
<table width="100%">
<tr><th>Params</th><th>Call Stack</th></tr>
<tr>
<td><?php var_dump($profile['parameters']); ?></td>
<td>
<table>
<tr>
<th></th>
<th>Location</th>
<th>Function/Method</th>
</tr>
<?php $stack = array_reverse($profile['stack']); ?>
<?php foreach ($stack as $index => $frame) : ?>
<tr>
<td><?=$index?></td>
<td><?=isset($frame['file'])?$frame['file'].':':''?><?=isset($frame['line'])?$frame['line']:''?></td>
<td><?= isset($frame['class']) ? $frame['class'] . '::' : '' ?><b><?=$frame['function']?></b></td>
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>
</table>
</td>
</tr>
<? endforeach; ?>
</table>
</div>
</div>
<script type="text/javascript">
var sqlDetail = function(id) {
$('#sqlDetail-'+id).toggle();
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment