File indexing completed on 2024-12-29 05:24:45

0001 <?php
0002 // get the default db adapter
0003 $adapter = Zend_Db_Table::getDefaultAdapter();
0004 $profiler = $adapter->getProfiler();
0005 if (Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') {
0006 
0007     if ($profiler->getEnabled() && $profiler->getTotalNumQueries() > 0) :
0008         ?>
0009         <div class="panel panel-default pull-left">
0010             <div class="panel-heading">
0011                 <h2>Database Profiling Report</h2>
0012                 <p>Total queries executed: <?php echo $profiler->getTotalNumQueries() ?></p>
0013                 <p>Total elapsed time: <?php echo $profiler->getTotalElapsedSecs() ?> seconds</p>
0014             </div>
0015             <div class="panel-body">
0016                 <table class="table table-bordered">
0017                     <thead>
0018                     <tr>
0019                         <th>#</th>
0020                         <th>Query</th>
0021                         <th>Params</th>
0022                         <th>Time</th>
0023                     </tr>
0024                     </thead>
0025                     <tbody>
0026                     <?php
0027                     /**
0028                      * @var int $queryNumber
0029                      * @var Zend_Db_Profiler_Query $query */
0030                     foreach ($profiler->getQueryProfiles() as $queryNumber => $query) : ?>
0031                         <tr>
0032                             <td width="10%">(<?php echo $queryNumber + 1 ?>)</td>
0033                             <td width="35%" style="word-wrap:break-word;"><?php echo $query->getQuery(); ?></td>
0034                             <td width="25%"><?php print_r($query->getQueryParams()); ?></td>
0035                             <td width="30%"><?php echo $query->getElapsedSecs(); ?> s</td>
0036                         </tr>
0037                     <?php endforeach ?>
0038                     </tbody>
0039                 </table>
0040             </div>
0041         </div>
0042     <?php endif ?>
0043 <?php }