Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12345 anikendra 1
<?php
2
/**
3
 * SQL Log Panel Element
4
 *
5
 * PHP 5
6
 *
7
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
9
 *
10
 * Licensed under The MIT License
11
 * Redistributions of files must retain the above copyright notice.
12
 *
13
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
14
 * @link          http://cakephp.org CakePHP(tm) Project
15
 * @since         DebugKit 0.1
16
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17
 */
18
 
19
$headers = array('Query', 'Affected', 'Num. rows', 'Took (ms)', 'Actions');
20
if (isset($debugKitInHistoryMode)) {
21
	$content = $this->Toolbar->readCache('sql_log', $this->request->params['pass'][0]);
22
}
23
?>
24
<h2><?php echo __d('debug_kit', 'Sql Logs')?></h2>
25
<?php if (!empty($content)) : ?>
26
	<?php foreach ($content['connections'] as $dbName => $explain): ?>
27
	<div class="sql-log-panel-query-log">
28
		<h4><?php echo $dbName ?></h4>
29
		<?php
30
			if (!isset($debugKitInHistoryMode)):
31
				$queryLog = $this->Toolbar->getQueryLogs($dbName, array(
32
					'explain' => $explain, 'threshold' => $content['threshold']
33
				));
34
			else:
35
				$queryLog = $content[$dbName];
36
			endif;
37
			if (empty($queryLog['queries'])):
38
				if (Configure::read('debug') < 2):
39
					echo ' ' . __d('debug_kit', 'No query logs when debug < 2.');
40
				else:
41
					echo ' ' . __d('debug_kit', 'No query logs.');
42
				endif;
43
			else:
44
				echo '<h5>';
45
				echo __d(
46
					'debug_kit',
47
					'Total Time: %s ms <br />Total Queries: %s queries',
48
					$queryLog['time'],
49
					$queryLog['count']
50
				);
51
				echo '</h5>';
52
				echo $this->Toolbar->table($queryLog['queries'], $headers, array('title' => 'SQL Log ' . $dbName));
53
			?>
54
		<h4><?php echo __d('debug_kit', 'Query Explain:'); ?></h4>
55
		<div id="sql-log-explain-<?php echo $dbName ?>">
56
			<a id="debug-kit-explain-<?php echo $dbName ?>"> </a>
57
			<p><?php echo __d('debug_kit', 'Click an "Explain" link above, to see the query explanation.'); ?></p>
58
		</div>
59
		<?php endif; ?>
60
	</div>
61
	<?php endforeach; ?>
62
<?php else:
63
	echo $this->Toolbar->message('Warning', __d('debug_kit', 'No active database connections'));
64
endif;