📄 index.php
字号:
/** * Prints out the cached information about the database. * * The DBAL caches a lot of information, e.g. about auto increment fields, * field types and primary keys. This method formats all this into a HTML * table to display in the BE. * * @return string HTML output */ function printCachedInfo() { // Get cmd: if((string)t3lib_div::_GP('cmd') == 'clear') { $GLOBALS['TYPO3_DB']->clearCachedFieldInfo(); $GLOBALS['TYPO3_DB']->cacheFieldInfo(); } $out = '<table border="1" cellspacing="0"><caption>auto_increment</caption><tbody><tr><th>Table</th><th>Field</th></tr>'; ksort($GLOBALS['TYPO3_DB']->cache_autoIncFields); foreach($GLOBALS['TYPO3_DB']->cache_autoIncFields as $table => $field) { $out .= '<tr>'; $out .= '<td>'.$table.'</td>'; $out .= '<td>'.$field.'</td>'; $out .= '</tr>'; } $out .= '</tbody></table>'; $out .= $this->doc->spacer(5); $out .= '<table border="1" cellspacing="0"><caption>Primary keys</caption><tbody><tr><th>Table</th><th>Field(s)</th></tr>'; ksort($GLOBALS['TYPO3_DB']->cache_primaryKeys); foreach($GLOBALS['TYPO3_DB']->cache_primaryKeys as $table => $field) { $out .= '<tr>'; $out .= '<td>'.$table.'</td>'; $out .= '<td>'.$field.'</td>'; $out .= '</tr>'; } $out .= '</tbody></table>'; $out .= $this->doc->spacer(5); $out .= '<table border="1" cellspacing="0"><caption>Field types</caption><tbody><tr><th colspan="4">Table</th></tr><tr><th>Field</th><th>Type</th><th>Metatype</th><th>NOT NULL</th></th></tr>'; ksort($GLOBALS['TYPO3_DB']->cache_fieldType); foreach($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fields) { $out .= '<th colspan="4">'.$table.'</th>'; foreach($fields as $field => $data) { $out .= '<tr>'; $out .= '<td>'.$field.'</td>'; $out .= '<td>'.$data['type'].'</td>'; $out .= '<td>'.$data['metaType'].'</td>'; $out .= '<td>'.$data['notnull'].'</td>'; $out .= '</tr>'; } } $out .= '</tbody></table>'; $menu = '<a href="index.php?cmd=clear">CLEAR DATA</a><hr />'; return $menu.$out; } /** * Printing the debug-log from the DBAL extension * * To enabled debugging, you will have to enabled it in the configuration! * * @return string HTML content */ function printLogMgm() { // Disable debugging in any case... $GLOBALS['TYPO3_DB']->debug = FALSE; // Get cmd: $cmd = (string)t3lib_div::_GP('cmd'); switch($cmd) { case 'flush': $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog',''); $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog_where',''); $outStr = 'Log FLUSHED!'; break; case 'joins': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('table_join,exec_time,query,script','tx_dbal_debuglog','table_join!=\'\'', 'table_join,script,exec_time,query'); // Init vars in which to pick up the query result: $tableIndex = array(); $tRows = array(); $tRows[] = ' <tr> <td>Execution time</td> <td>Table joins</td> <td>Script</td> <td>Query</td> </tr>'; while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tableArray = $GLOBALS['TYPO3_DB']->SQLparser->parseFromTables($row['table_join']); // Create table name index: foreach($tableArray as $a) { foreach($tableArray as $b) { if ($b['table']!=$a['table']) { $tableIndex[$a['table']][$b['table']]=1; } } } // Create output row $tRows[] = ' <tr> <td>'.htmlspecialchars($row['exec_time']).'</td> <td>'.htmlspecialchars($row['table_join']).'</td> <td>'.htmlspecialchars($row['script']).'</td> <td>'.htmlspecialchars($row['query']).'</td> </tr>'; } // Printing direct joins: $outStr.= '<h4>Direct joins:</h4>'.t3lib_div::view_array($tableIndex); // Printing total dependencies: foreach($tableIndex as $priTable => $a) { foreach($tableIndex as $tableN => $v) { foreach($v as $tableP => $vv) { if ($tableP == $priTable) { $tableIndex[$priTable] = array_merge($v, $a); } } } } $outStr.= '<h4>Total dependencies:</h4>'.t3lib_div::view_array($tableIndex); // Printing data rows: $outStr.= ' <table border="1" cellspacing="0">'.implode('',$tRows).' </table>'; break; case 'errors': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('serdata,exec_time,query,script','tx_dbal_debuglog','errorFlag>0','','tstamp DESC'); // Init vars in which to pick up the query result: $tRows = array(); $tRows[] = ' <tr> <td>Execution time</td> <td>Error data</td> <td>Script</td> <td>Query</td> </tr>'; while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Create output row $tRows[] = ' <tr> <td>'.htmlspecialchars($row['exec_time']).'</td> <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td> <td>'.htmlspecialchars($row['script']).'</td> <td>'.htmlspecialchars($row['query']).'</td> </tr>'; } // Printing data rows: $outStr.= ' <table border="1" cellspacing="0">'.implode('',$tRows).' </table>'; break; case 'parsing': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('query,serdata','tx_dbal_debuglog','errorFlag&2=2'); $tRows = array(); while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // Create output row $tRows[] = ' <tr> <td>'.htmlspecialchars($row['query']).'</td> </tr>'; } // Printing data rows: $outStr.= ' <table border="1" cellspacing="0">'.implode('',$tRows).' </table>'; break; case 'where': $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script,tablename,whereclause','tx_dbal_debuglog_where','','','tstamp DESC'); $tRows = array(); $tRows[] = ' <tr> <td>Time</td> <td>Script</td> <td>Table</td> <td>WHERE clause</td> </tr>'; while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tRows[] = ' <tr> <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td> <td>'.htmlspecialchars($row['script']).'</td> <td>'.htmlspecialchars($row['tablename']).'</td> <td>'.str_replace(array('\'\'','""','IS NULL','IS NOT NULL'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>','<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row['whereclause'])).'</td> </tr>'; } $outStr = ' <table border="1" cellspacing="0">'.implode('',$tRows).' </table>'; break; default: // Look for request to view specific script exec: $specTime = t3lib_div::_GP('specTime'); if ($specTime) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_dbal_debuglog','tstamp='.intval($specTime)); $tRows = array(); $tRows[] = ' <tr> <td>Execution time</td> <td>Error</td> <td>Table joins</td> <td>Data</td> <td>Query</td> </tr>'; while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tRows[] = ' <tr> <td>'.htmlspecialchars($row['exec_time']).'</td> <td>'.($row['errorFlag'] ? 1 : 0).'</td> <td>'.htmlspecialchars($row['table_join']).'</td> <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td> <td>'.str_replace(array('\'\'','""','IS NULL','IS NOT NULL'), array('<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">\'\'</span>','<span style="background-color:#ff0000;color:#ffffff;padding:2px;font-weight:bold;">""</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NULL</span>','<span style="background-color:#00ff00;color:#ffffff;padding:2px;font-weight:bold;">IS NOT NULL</span>'), htmlspecialchars($row['query'])).'</td> </tr>'; } } else { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script, SUM(exec_time) as calc_sum, count(*) AS qrycount, MAX(errorFlag) as error','tx_dbal_debuglog','','tstamp,script','tstamp DESC'); $tRows = array(); $tRows[] = ' <tr> <td>Time</td> <td># of queries</td> <td>Error</td> <td>Time (ms)</td> <td>Script</td> </tr>'; while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $tRows[] = ' <tr> <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td> <td>'.htmlspecialchars($row['qrycount']).'</td> <td>'.($row['error'] ? '<strong style="color:#f00">ERR</strong>' : '').'</td> <td>'.htmlspecialchars($row['calc_sum']).'</td> <td><a href="index.php?specTime='.intval($row['tstamp']).'">'.htmlspecialchars($row['script']).'</a></td> </tr>'; } } $outStr = ' <table border="1" cellspacing="0">'.implode('',$tRows).' </table>'; break; } $menu = ' <a href="index.php?cmd=flush">FLUSH LOG</a> - <a href="index.php?cmd=joins">JOINS</a> - <a href="index.php?cmd=errors">ERRORS</a> - <a href="index.php?cmd=parsing">PARSING</a> - <a href="index.php">LOG</a> - <a href="index.php?cmd=where">WHERE</a> - <a href="'.htmlspecialchars(t3lib_div::linkThisScript()).'" target="tx_debuglog">[New window]</a> <hr /> '; return $menu.$outStr; }}if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']);} // Make instance:$SOBE = t3lib_div::makeInstance('tx_dbal_module1');$SOBE->init();$SOBE->main();$SOBE->printContent();?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -