Documentation TYPO3 par Ameos

index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2004, 2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  (c) 2004, 2005 Karsten Dambekalns (karsten@typo3.org)
00007 *  All rights reserved
00008 *
00009 *  This script is part of the TYPO3 project. The TYPO3 project is
00010 *  free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  The GNU General Public License can be found at
00016 *  http://www.gnu.org/copyleft/gpl.html.
00017 *
00018 *  This script is distributed in the hope that it will be useful,
00019 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 *  GNU General Public License for more details.
00022 *
00023 *  This copyright notice MUST APPEAR in all copies of the script!
00024 ***************************************************************/
00032 unset($MCONF);
00033 require ('conf.php');
00034 require ($BACK_PATH.'init.php');
00035 require ($BACK_PATH.'template.php');
00036 $LANG->includeLLFile('EXT:dbal/mod1/locallang.xml');
00037 require_once (PATH_t3lib.'class.t3lib_scbase.php');
00038 $BE_USER->modAccess($MCONF,1);
00039 
00040 
00049 class tx_dbal_module1 extends t3lib_SCbase {
00050 
00056         function menuConfig()   {
00057                 $this->MOD_MENU = Array (
00058                         'function' => Array (
00059                                 0 => $GLOBALS['LANG']->getLL('Debug_log'),
00060                                 'info' => $GLOBALS['LANG']->getLL('Cached_info'),
00061                                 'sqlcheck' => $GLOBALS['LANG']->getLL('SQL_check'),
00062                         )
00063                 );
00064                 parent::menuConfig();
00065         }
00066 
00072         function main() {
00073                 global $BACK_PATH,$BE_USER;
00074 
00075                         // Clean up settings:
00076                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00077 
00078                         // Draw the header.
00079                 $this->doc = t3lib_div::makeInstance('noDoc');
00080                 $this->doc->backPath = $BACK_PATH;
00081                 $this->doc->form='<form action="" method="post">';
00082                 $this->doc->docType = 'xhtml_trans';
00083 
00084                         // JavaScript
00085                 $this->doc->JScode = $this->doc->wrapScriptTags('
00086                                 script_ended = 0;
00087                                 function jumpToUrl(URL) {       //
00088                                         window.location.href = URL;
00089                                 }
00090                         ');
00091 
00092                         // DBAL page title:
00093                 $this->content.=$this->doc->startPage($GLOBALS['LANG']->getLL('title'));
00094                 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('title'));
00095                 $this->content.=$this->doc->spacer(5);
00096                 $this->content.=$this->doc->section('',$this->doc->funcMenu('',t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'])));
00097 
00098                         // Debug log:
00099                 switch($this->MOD_SETTINGS['function']) {
00100                         case 'info':
00101                         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Cached_info'), $this->printCachedInfo());
00102                         break;
00103                         case 'sqlcheck':
00104                         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('SQL_check'), $this->printSqlCheck());
00105                         break;
00106                         case 0:
00107                         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('Debug_log'), $this->printLogMgm());
00108                         break;
00109                 }
00110 
00111                         // ShortCut
00112                 if ($BE_USER->mayMakeShortcut())        {
00113                         $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
00114                 }
00115 
00116                 $this->content.=$this->doc->spacer(10);
00117         }
00118 
00124         function printContent() {
00125                 global $SOBE;
00126 
00127                 $this->content.=$this->doc->middle();
00128                 $this->content.=$this->doc->endPage();
00129                 echo $this->content;
00130         }
00131 
00137         function printSqlCheck()        {
00138                 $input = t3lib_div::_GP('tx_dbal');
00139 
00140                 $out = '
00141                         <form name="sql_check" action="index.php" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
00142                         <script type="text/javascript">
00143 /*<![CDATA[*/
00144 function updateQryForm(s) {
00145         document.getElementById(\'tx-dbal-result\').style.display = \'none\';
00146         switch(s) {
00147         case \'SELECT\':
00148                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'table-row\';
00149                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
00150                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
00151                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\';
00152                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
00153                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00154                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\';
00155                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\';
00156                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\';
00157         break;
00158         case \'INSERT\':
00159                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
00160                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'table-row\';
00161                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
00162                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\';
00163                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'table-row\';
00164                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00165                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'table-row\';
00166                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'table-row\';
00167                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'table-row\';
00168         break;
00169         case \'UPDATE\':
00170                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
00171                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
00172                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'table-row\';
00173                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'none\';
00174                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
00175                 document.getElementById(\'tx-dbal-qryupdate\').style.display = \'table-row\';
00176                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00177                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\';
00178                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\';
00179                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\';
00180         break;
00181         case \'DELETE\':
00182                 document.getElementById(\'tx-dbal-qryfields\').style.display = \'none\';
00183                 document.getElementById(\'tx-dbal-qryinsertvalues\').style.display = \'none\';
00184                 document.getElementById(\'tx-dbal-qryupdatevalues\').style.display = \'none\';
00185                 document.getElementById(\'tx-dbal-qryfrom\').style.display = \'table-row\';
00186                 document.getElementById(\'tx-dbal-qryinto\').style.display = \'none\';
00187                 document.getElementById(\'tx-dbal-qrywhere\').style.display = \'table-row\';
00188                 document.getElementById(\'tx-dbal-qrygroup\').style.display = \'none\';
00189                 document.getElementById(\'tx-dbal-qryorder\').style.display = \'none\';
00190                 document.getElementById(\'tx-dbal-qrylimit\').style.display = \'none\';
00191         break;
00192         }
00193 }
00194 /*]]>*/
00195                                 </script>
00196             <table>
00197             <tr class="tableheader bgColor5"><th colspan="2">Easy SQL check</th></tr>
00198             <tr><td colspan="2">
00199             <select name="tx_dbal[QUERY]"size="1" onchange="updateQryForm(this.options[this.selectedIndex].value)">
00200              <option value="SELECT" '.($input['QUERY']=='SELECT'? 'selected="selected"' : '').'>SELECT</option>
00201              <option value="INSERT" '.($input['QUERY']=='INSERT'? 'selected="selected"' : '').'>INSERT</option>
00202              <option value="UPDATE" '.($input['QUERY']=='UPDATE'? 'selected="selected"' : '').'>UPDATE</option>
00203              <option value="DELETE" '.($input['QUERY']=='DELETE' ? 'selected="selected"' : '').'">DELETE</option>
00204             </select>
00205             </td></tr>
00206             <tr id="tx-dbal-qryupdate" style="display:none;"><td></td><td><input name="tx_dbal[UPDATE]" value="'.$input['UPDATE'].'" type="text" size="30" maxsize="100" /></td></tr>
00207             <tr id="tx-dbal-qryfields"><td></td><td><input name="tx_dbal[FIELDS]" value="'.$input['FIELDS'].'" type="text" size="30" maxsize="100" /></td></tr>
00208             <tr id="tx-dbal-qryinsertvalues" style="display:none;"><td></td><td><textarea name="tx_dbal[INSERTVALUES]" cols="30" rows="4">'.$input['INSERTVALUES'].'</textarea></td></tr>
00209             <tr id="tx-dbal-qryupdatevalues" style="display:none;"><th>SET</th><td><textarea name="tx_dbal[UPDATEVALUES]" cols="30" rows="4">'.$input['UPDATEVALUES'].'</textarea></td></tr>
00210             <tr id="tx-dbal-qryfrom"><th>FROM</th><td><input name="tx_dbal[FROM]" value="'.$input['FROM'].'" type="text" size="30" maxsize="100" /></td></tr>
00211             <tr id="tx-dbal-qryinto" style="display:none;"><th>INTO</th><td><input name="tx_dbal[INTO]" value="'.$input['INTO'].'" type="text" size="30" maxsize="100" /></td></tr>
00212             <tr id="tx-dbal-qrywhere"><th>WHERE</th><td><input name="tx_dbal[WHERE]" value="'.$input['WHERE'].'" type="text" size="30" maxsize="100" /></td></tr>
00213             <tr id="tx-dbal-qrygroup"><th>GROUP BY</th><td><input name="tx_dbal[GROUP]" value="'.$input['GROUP'].'" type="text" size="30" maxsize="100" /></td></tr>
00214             <tr id="tx-dbal-qryorder"><th>ORDER BY</th><td><input name="tx_dbal[ORDER]" value="'.$input['ORDER'].'" type="text" size="30" maxsize="100" /></td></tr>
00215             <tr id="tx-dbal-qrylimit"><th>LIMIT</th><td><input name="tx_dbal[LIMIT]" value="'.$input['LIMIT'].'" type="text" size="30" maxsize="100" /></td></tr>
00216                         <tr><td></td><td style="text-align:right;"><input type="submit" value="CHECK" /></td></tr>
00217                         <script type="text/javascript">
00218 /*<![CDATA[*/
00219 updateQryForm(\''.$input['QUERY'].'\');
00220 /*]]>*/
00221                                 </script>
00222                         ';
00223 
00224                 $out .= '<tr id="tx-dbal-result" class="bgColor4"><th>Result:</th><td>';
00225                 switch($input['QUERY']) {
00226                         case 'SELECT':
00227                         $qry = $GLOBALS['TYPO3_DB']->SELECTquery($input['FIELDS'],$input['FROM'],$input['WHERE'],$input['GROUP'],$input['ORDER'],$input['LIMIT']);
00228                         break;
00229                         case 'INSERT':
00230                         $qry = $GLOBALS['TYPO3_DB']->INSERTquery($input['INTO'],$this->createFieldsValuesArray($input['INSERTVALUES']));
00231                         break;
00232                         case 'UPDATE':
00233                         $qry = $GLOBALS['TYPO3_DB']->UPDATEquery($input['UPDATE'],$input['WHERE'],$this->createFieldsValuesArray($input['UPDATEVALUES']));
00234                         break;
00235                         case 'DELETE':
00236                         $qry = $GLOBALS['TYPO3_DB']->DELETEquery($input['FROM'],$input['WHERE']);
00237                         break;
00238                 }
00239                 $out .= '<pre>'.htmlspecialchars($qry).'</pre></td></tr>';
00240 
00241                 $out .= '
00242                         <tr class="tableheader bgColor5"><th colspan="2">RAW SQL check</th></tr>
00243                         <tr><td colspan="2" style="text-align:right;"><textarea name="tx_dbal[RAWSQL]" cols="60" rows="5">'.$input['RAWSQL'].'</textarea><br /><input type="submit" value="CHECK" /></td></tr>';
00244                 if(!empty($input['RAWSQL'])) {
00245                         $out .= '<tr class="bgColor4">';
00246                         $parseResult = $GLOBALS['TYPO3_DB']->SQLparser->parseSQL($input['RAWSQL']);
00247                         if (is_array($parseResult))     {
00248                                 $newQuery = $GLOBALS['TYPO3_DB']->SQLparser->compileSQL($parseResult);
00249                                 $testResult = $GLOBALS['TYPO3_DB']->SQLparser->debug_parseSQLpartCompare($input['RAWSQL'], $newQuery);
00250                                 if (!is_array($testResult))     {
00251                                         $out .= '<td colspan="2">'.$newQuery;
00252                                 } else {
00253                                         $out .= '<td colspan="2">'.htmlspecialchars($testResult[0]).'</td></tr>
00254                                         <tr><th>Error:</th><td style="border:2px solid #f00;">Input query did not match the parsed and recompiled query exactly (not observing whitespace):<br />'.htmlspecialchars($testResult[1]);
00255                                 }
00256                         } else {
00257                                 $out .= '<th>Result:</th><td style="border:2px solid #f00;">'.$parseResult;
00258                         }
00259                         $out .='</td></tr>';
00260                 }
00261 
00262                 $out .='</table></form>';
00263                 return $out;
00264         }
00265 
00275         function createFieldsValuesArray($in) {
00276                 $ret = array();
00277                 $in = explode(chr(10),$in);
00278                 foreach ($in as $v) {
00279                         $fv = explode('=',$v);
00280                         $ret[$fv[0]] = $fv[1];
00281                 }
00282 
00283                 return $ret;
00284         }
00285 
00295         function printCachedInfo()      {
00296                         // Get cmd:
00297                 if((string)t3lib_div::_GP('cmd') == 'clear') {
00298                         $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
00299                         $GLOBALS['TYPO3_DB']->cacheFieldInfo();
00300                 }
00301 
00302                 $out = '<table border="1" cellspacing="0"><caption>auto_increment</caption><tbody><tr><th>Table</th><th>Field</th></tr>';
00303                 ksort($GLOBALS['TYPO3_DB']->cache_autoIncFields);
00304                 foreach($GLOBALS['TYPO3_DB']->cache_autoIncFields as $table => $field) {
00305                         $out .= '<tr>';
00306                         $out .= '<td>'.$table.'</td>';
00307                         $out .= '<td>'.$field.'</td>';
00308                         $out .= '</tr>';
00309                 }
00310                 $out .= '</tbody></table>';
00311                 $out .= $this->doc->spacer(5);
00312                 $out .= '<table border="1" cellspacing="0"><caption>Primary keys</caption><tbody><tr><th>Table</th><th>Field(s)</th></tr>';
00313                 ksort($GLOBALS['TYPO3_DB']->cache_primaryKeys);
00314                 foreach($GLOBALS['TYPO3_DB']->cache_primaryKeys as $table => $field) {
00315                         $out .= '<tr>';
00316                         $out .= '<td>'.$table.'</td>';
00317                         $out .= '<td>'.$field.'</td>';
00318                         $out .= '</tr>';
00319                 }
00320                 $out .= '</tbody></table>';
00321                 $out .= $this->doc->spacer(5);
00322                 $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>';
00323                 ksort($GLOBALS['TYPO3_DB']->cache_fieldType);
00324                 foreach($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fields) {
00325                         $out .= '<th colspan="4">'.$table.'</th>';
00326                         foreach($fields as $field => $data) {
00327                                 $out .= '<tr>';
00328                                 $out .= '<td>'.$field.'</td>';
00329                                 $out .= '<td>'.$data['type'].'</td>';
00330                                 $out .= '<td>'.$data['metaType'].'</td>';
00331                                 $out .= '<td>'.$data['notnull'].'</td>';
00332                                 $out .= '</tr>';
00333                         }
00334                 }
00335                 $out .= '</tbody></table>';
00336 
00337                 $menu = '<a href="index.php?cmd=clear">CLEAR DATA</a><hr />';
00338 
00339                 return $menu.$out;
00340         }
00341 
00349         function printLogMgm()  {
00350 
00351                         // Disable debugging in any case...
00352                 $GLOBALS['TYPO3_DB']->debug = FALSE;
00353 
00354                         // Get cmd:
00355                 $cmd = (string)t3lib_div::_GP('cmd');
00356                 switch($cmd)    {
00357                         case 'flush':
00358                         $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog','');
00359                         $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dbal_debuglog_where','');
00360                         $outStr = 'Log FLUSHED!';
00361                         break;
00362                         case 'joins':
00363 
00364                                 // Query:
00365                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('table_join,exec_time,query,script','tx_dbal_debuglog','table_join!=\'\'', 'table_join,script,exec_time,query');
00366 
00367                                 // Init vars in which to pick up the query result:
00368                         $tableIndex = array();
00369                         $tRows = array();
00370                         $tRows[] = '
00371                                         <tr>
00372                                                 <td>Execution time</td>
00373                                                 <td>Table joins</td>
00374                                                 <td>Script</td>
00375                                                 <td>Query</td>
00376                                         </tr>';
00377 
00378                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00379                                 $tableArray = $GLOBALS['TYPO3_DB']->SQLparser->parseFromTables($row['table_join']);
00380 
00381                                 // Create table name index:
00382                                 foreach($tableArray as $a)      {
00383                                         foreach($tableArray as $b)      {
00384                                                 if ($b['table']!=$a['table'])   {
00385                                                         $tableIndex[$a['table']][$b['table']]=1;
00386                                                 }
00387                                         }
00388                                 }
00389 
00390                                         // Create output row
00391                                 $tRows[] = '
00392                                                 <tr>
00393                                                         <td>'.htmlspecialchars($row['exec_time']).'</td>
00394                                                         <td>'.htmlspecialchars($row['table_join']).'</td>
00395                                                         <td>'.htmlspecialchars($row['script']).'</td>
00396                                                         <td>'.htmlspecialchars($row['query']).'</td>
00397                                                 </tr>';
00398                         }
00399 
00400                                 // Printing direct joins:
00401                         $outStr.= '<h4>Direct joins:</h4>'.t3lib_div::view_array($tableIndex);
00402 
00403 
00404                                 // Printing total dependencies:
00405                         foreach($tableIndex as $priTable => $a) {
00406                                 foreach($tableIndex as $tableN => $v)   {
00407                                         foreach($v as $tableP => $vv)   {
00408                                                 if ($tableP == $priTable)       {
00409                                                         $tableIndex[$priTable] = array_merge($v, $a);
00410                                                 }
00411                                         }
00412                                 }
00413                         }
00414                         $outStr.= '<h4>Total dependencies:</h4>'.t3lib_div::view_array($tableIndex);
00415 
00416                                 // Printing data rows:
00417                         $outStr.= '
00418                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00419                                         </table>';
00420                         break;
00421                         case 'errors':
00422 
00423                                 // Query:
00424                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('serdata,exec_time,query,script','tx_dbal_debuglog','errorFlag>0','','tstamp DESC');
00425 
00426                                 // Init vars in which to pick up the query result:
00427                         $tRows = array();
00428                         $tRows[] = '
00429                                         <tr>
00430                                                 <td>Execution time</td>
00431                                                 <td>Error data</td>
00432                                                 <td>Script</td>
00433                                                 <td>Query</td>
00434                                         </tr>';
00435 
00436                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00437                                         // Create output row
00438                                 $tRows[] = '
00439                                                 <tr>
00440                                                         <td>'.htmlspecialchars($row['exec_time']).'</td>
00441                                                         <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td>
00442                                                         <td>'.htmlspecialchars($row['script']).'</td>
00443                                                         <td>'.htmlspecialchars($row['query']).'</td>
00444                                                 </tr>';
00445                         }
00446 
00447                                 // Printing data rows:
00448                         $outStr.= '
00449                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00450                                         </table>';
00451                         break;
00452                         case 'parsing':
00453                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('query,serdata','tx_dbal_debuglog','errorFlag&2=2');
00454                         $tRows = array();
00455                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00456                                         // Create output row
00457                                 $tRows[] = '
00458                                                 <tr>
00459                                                         <td>'.htmlspecialchars($row['query']).'</td>
00460                                                 </tr>';
00461                         }
00462 
00463                                 // Printing data rows:
00464                         $outStr.= '
00465                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00466                                         </table>';
00467                         break;
00468                         case 'where':
00469                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp,script,tablename,whereclause','tx_dbal_debuglog_where','','','tstamp DESC');
00470                         $tRows = array();
00471                         $tRows[] = '
00472                                         <tr>
00473                                                 <td>Time</td>
00474                                                 <td>Script</td>
00475                                                 <td>Table</td>
00476                                                 <td>WHERE clause</td>
00477                                         </tr>';
00478                         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00479                                 $tRows[] = '
00480                                                 <tr>
00481                                                         <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td>
00482                                                         <td>'.htmlspecialchars($row['script']).'</td>
00483                                                         <td>'.htmlspecialchars($row['tablename']).'</td>
00484                                                         <td>'.str_replace(array('\'\'','""'), 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>'), htmlspecialchars($row['whereclause'])).'</td>
00485                                                 </tr>';
00486                         }
00487 
00488                         $outStr = '
00489                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00490                                         </table>';
00491                         break;
00492                         default:
00493 
00494                                 // Look for request to view specific script exec:
00495                         $specTime = t3lib_div::_GP('specTime');
00496 
00497                         if ($specTime)  {
00498                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tx_dbal_debuglog','tstamp='.intval($specTime));
00499                                 $tRows = array();
00500                                 $tRows[] = '
00501                                                 <tr>
00502                                                         <td>Execution time</td>
00503                                                         <td>Error</td>
00504                                                         <td>Table joins</td>
00505                                                         <td>Data</td>
00506                                                         <td>Query</td>
00507                                                 </tr>';
00508                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00509                                         $tRows[] = '
00510                                                         <tr>
00511                                                                 <td>'.htmlspecialchars($row['exec_time']).'</td>
00512                                                                 <td>'.($row['errorFlag'] ? 1 : 0).'</td>
00513                                                                 <td>'.htmlspecialchars($row['table_join']).'</td>
00514                                                                 <td>'.t3lib_div::view_array(unserialize($row['serdata'])).'</td>
00515                                                                 <td>'.htmlspecialchars($row['query']).'</td>
00516                                                         </tr>';
00517                                 }
00518                         } else {
00519                                 $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');
00520                                 $tRows = array();
00521                                 $tRows[] = '
00522                                                 <tr>
00523                                                         <td>Time</td>
00524                                                         <td># of queries</td>
00525                                                         <td>Error</td>
00526                                                         <td>Time (ms)</td>
00527                                                         <td>Script</td>
00528                                                 </tr>';
00529                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
00530                                         $tRows[] = '
00531                                                         <tr>
00532                                                                 <td>'.t3lib_BEfunc::datetime($row['tstamp']).'</td>
00533                                                                 <td>'.htmlspecialchars($row['qrycount']).'</td>
00534                                                                 <td>'.($row['error'] ? '<strong style="color:#f00">ERR</strong>' : '').'</td>
00535                                                                 <td>'.htmlspecialchars($row['calc_sum']).'</td>
00536                                                                 <td><a href="index.php?specTime='.intval($row['tstamp']).'">'.htmlspecialchars($row['script']).'</a></td>
00537                                                         </tr>';
00538                                 }
00539                         }
00540                         $outStr = '
00541                                         <table border="1" cellspacing="0">'.implode('',$tRows).'
00542                                         </table>';
00543 
00544                         break;
00545                 }
00546 
00547                 $menu = '
00548                                         <a href="index.php?cmd=flush">FLUSH LOG</a> -
00549                                         <a href="index.php?cmd=joins">JOINS</a> -
00550                                         <a href="index.php?cmd=errors">ERRORS</a> -
00551                                         <a href="index.php?cmd=parsing">PARSING</a> -
00552                                         <a href="index.php">LOG</a> -
00553                                         <a href="index.php?cmd=where">WHERE</a> -
00554 
00555                                         <a href="'.htmlspecialchars(t3lib_div::linkThisScript()).'" target="tx_debuglog">[New window]</a>
00556                                         <hr />
00557                 ';
00558                 return $menu.$outStr;
00559         }
00560 }
00561 
00562 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']) {
00563         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/mod1/index.php']);
00564 }
00565 
00566 
00567 
00568 
00569         // Make instance:
00570 $SOBE = t3lib_div::makeInstance('tx_dbal_module1');
00571 $SOBE->init();
00572 $SOBE->main();
00573 $SOBE->printContent();
00574 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6