Changeset 1373
- Timestamp:
- 01/03/12 10:16:49 (18 months ago)
- Location:
- framework/branches/2.0
- Files:
-
- 5 modified
-
assets/_core/php/profile.php (modified) (5 diffs)
-
includes/qcubed/_core/database/QMySqliDatabase.class.php (modified) (1 diff)
-
includes/qcubed/_core/database/QOracleDatabase.class.php (modified) (1 diff)
-
includes/qcubed/_core/database/QPostgreSqlDatabase.class.php (modified) (1 diff)
-
includes/qcubed/_core/framework/QDatabaseBase.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
framework/branches/2.0/assets/_core/php/profile.php
r936 r1373 15 15 $objProfileArray = QType::Cast($objProfileArray, QType::ArrayType); 16 16 $intCount = count($objProfileArray); 17 18 function PrintExplainStatement($strOriginalQuery) { 19 global $intDatabaseIndex; 20 if (substr_count($strOriginalQuery, "AUTOCOMMIT=1") > 0) { 21 return null; 22 } 23 $result = ""; 24 25 $objDb = QApplication::$Database[$intDatabaseIndex]; 26 $objDbResult = $objDb->ExplainStatement($strOriginalQuery); 27 if (!$objDbResult) { 28 return ""; 29 } 30 31 $result .= "<table class='explainTable' border=1>"; 32 $headersShown = false; 33 while ($mixRow = $objDbResult->FetchArray()) { 34 if (!$headersShown) { 35 $result .= "<thead class='header'>"; 36 foreach ($mixRow as $key=>$value) { 37 if (!is_numeric($key)) { 38 $result .= "<td>" . $key . "</td>"; 39 $headersShown = true; 40 } 41 } 42 $result .= '</thead>'; 43 } 44 $result .= "<tr>"; 45 foreach ($mixRow as $key=>$value) { 46 if (!is_numeric($key)) { 47 $result .= "<td>" . $value . "</td>"; 48 } 49 } 50 $result .= "</tr>"; 51 } 52 $result .= "</table>"; 53 return $result; 54 } 17 55 ?> 18 56 <!DOCTYPE html> … … 21 59 <title>QCubed Development Framework - Database Profiling Tool</title> 22 60 <style type="text/css">@import url("<?php _p(__VIRTUAL_DIRECTORY__ . __CSS_ASSETS__); ?>/corepage.css");</style> 61 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 23 62 <script type="text/javascript"> 24 function Toggle(strWhatId , strButtonId) {63 function Toggle(strWhatId) { 25 64 var obj = document.getElementById(strWhatId); 26 var objButton = document.getElementById( strButtonId);65 var objButton = document.getElementById("button" + strWhatId); 27 66 28 67 if (obj && objButton) { 29 68 if (obj.style.display == "block") { 30 69 obj.style.display = "none"; 31 objButton.innerHTML = "Show"; 32 } 70 objButton.innerHTML = objButton.innerHTML.replace("Hide", "Show"); 71 } 72 33 73 else { 34 74 obj.style.display = "block"; 35 objButton.innerHTML = "Hide";75 objButton.innerHTML = objButton.innerHTML.replace("Show", "Hide"); 36 76 } 37 77 } … … 40 80 41 81 function ShowAll() { 42 for (var intIndex = 1; intIndex <= <?php _p($intCount); ?>; intIndex++) {43 var objQuery = document.getElementById('query' + intIndex);44 var objButton = document.getElementById('button' + intIndex);45 objQuery.style.display = "block";46 objButton.innerHTML = "Hide";47 } 82 jQuery(".querySection, .explainSection").each(function() { 83 if ($(this).css('display') == "none") { 84 Toggle(this.id); 85 } 86 }); 87 48 88 return false; 49 89 } 50 90 51 91 function HideAll() { 52 for (var intIndex = 1; intIndex <= <?php _p($intCount); ?>; intIndex++) { 53 var objQuery = document.getElementById('query' + intIndex); 54 var objButton = document.getElementById('button' + intIndex); 55 objQuery.style.display = "none"; 56 objButton.innerHTML = "Show"; 57 } 92 jQuery(".querySection, .explainSection").each(function() { 93 if ($(this).css('display') == "block") { 94 Toggle(this.id); 95 } 96 }); 58 97 return false; 59 98 } 60 99 </script> 100 <style> 101 .explainTable { 102 border: 1px solid black; 103 border-collapse:collapse; 104 margin-top: 5px; 105 } 106 .explainTable td { 107 padding: 4px; 108 } 109 .explainTable .header td { 110 background: #CCC; 111 font-weight: bold; 112 } 113 </style> 61 114 </head> 62 115 <body> … … 115 168 <span class="function"> 116 169 Called by <?php _p($strClass . $strType . $strFunction . '(' . implode(', ', $objArgs) . ')'); ?> 117 <a href="#" onClick="return Toggle('query<?php _p($intIndex); ?>', 'button<?php _p($intIndex); ?>')" id="button<?php _p($intIndex); ?>" class="smallbutton">118 Show119 </a>120 170 </span> <br/> 121 171 <span class="function_details"> 122 172 <b>File: </b><?php _p($strFile); ?>; <b>Line: </b><?php _p($strLine); ?> 123 173 </span> 124 <pre id="query<?php _p($intIndex); ?>" style="display: none"><code><?php _p($strQuery); ?></code></pre>125 174 <?php 126 175 //mark slow query - those that take over 1 second … … 130 179 echo'<div class="time">'; 131 180 printf("Query took %.1f ms", $dblTimeInfo * 1000); 181 ?> 182 <?php $explainStatement = PrintExplainStatement($strQuery); ?> 183 <a href="#" onClick="return Toggle('query<?php _p($intIndex); ?>')" id="buttonquery<?php _p($intIndex); ?>" class="queryButton smallbutton"> 184 Show SQL 185 </a> 186 <?php if ($explainStatement) { ?> 187 188 <a href="#" onClick="return Toggle('explain<?php _p($intIndex); ?>')" id="buttonexplain<?php _p($intIndex); ?>" class="explainButton smallbutton"> 189 Show EXPLAIN statement 190 </a> 191 <?php } ?> 192 193 <pre id="query<?php _p($intIndex); ?>" style="display: none" class="querySection"><code><?php _p($strQuery); ?></code></pre> 194 <div id="explain<?php _p($intIndex); ?>" style="display: none" class="explainSection"><?php echo $explainStatement; ?></div> 195 <?php 132 196 echo '</div>'; 133 197 ?> -
framework/branches/2.0/includes/qcubed/_core/database/QMySqliDatabase.class.php
r1368 r1373 381 381 throw new Exception("Invalid Table Description"); 382 382 } 383 384 public function ExplainStatement($sql) { 385 return $this->Query("EXPLAIN " . $sql); 386 } 383 387 } 384 388 -
framework/branches/2.0/includes/qcubed/_core/database/QOracleDatabase.class.php
r1368 r1373 567 567 throw new Exception("Invalid Table Description"); 568 568 } 569 570 public function ExplainStatement($sql) { 571 return $this->Query("EXPLAIN PLAN FOR " . $sql); 572 } 569 573 } 570 574 -
framework/branches/2.0/includes/qcubed/_core/database/QPostgreSqlDatabase.class.php
r1368 r1373 420 420 return $objForeignKeyArray; 421 421 } 422 423 public function ExplainStatement($sql) { 424 return $this->Query("EXPLAIN " . $sql); 425 } 422 426 } 423 427 -
framework/branches/2.0/includes/qcubed/_core/framework/QDatabaseBase.class.php
r1370 r1373 391 391 } 392 392 } 393 394 /** 395 * Executes the explain statement for a given query and returns the output without any transformation. 396 * If the database adapter does not support EXPLAIN statements, returns null. 397 * 398 * @param $strSql 399 */ 400 public function ExplainStatement($sql) { 401 return null; 402 } 393 403 } 394 404
