Ignore:
Timestamp:
Oct 30, 2004, 5:42:29 PM (19 years ago)
Author:
z0rglub
Message:
  • function mysql_query replaced by pwg_query : the same with debugging features
  • by default, DEBUG is set to 0 (off)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r579 r587  
    5252  // retrieving the properties of the table. Each line represents a field :
    5353  // columns are 'Field', 'Type'
    54   $result=mysql_query("desc $table");
     54  $result=pwg_query("desc $table");
    5555  while ( $row = mysql_fetch_array( $result ) )
    5656  {
     
    351351    $query.= ",'".$_SERVER['REMOTE_ADDR']."'";
    352352    $query.= ",'".$file."','".$category."','".$picture."');";
    353     mysql_query( $query );
     353    pwg_query( $query );
    354354  }
    355355}
     
    409409  $query.= ' AND mail_address IS NOT NULL';
    410410  $query.= ';';
    411   $result = mysql_query( $query );
     411  $result = pwg_query( $query );
    412412  while ( $row = mysql_fetch_array( $result ) )
    413413  {
     
    445445}
    446446
    447 function pwg_query( $query )
    448 {
    449   global $count_queries,$queries_time;
    450 
     447function pwg_query($query)
     448{
    451449  $start = get_moment();
    452   $output = '';
    453  
    454   $count_queries++;
    455   $output.= '<br /><br />['.$count_queries.'] '.$query;
    456   $result = mysql_query( $query );
    457   $time = get_moment() - $start;
    458   $queries_time+= $time;
    459   $output.= '<b>('.number_format( $time, 3, '.', ' ').' s)</b>';
    460   $output.= '('.number_format( $queries_time, 3, '.', ' ').' s)';
    461 
    462   // echo $output;
     450  $result = mysql_query($query);
     451
     452  if (DEBUG)
     453  {
     454    global $count_queries,$queries_time;
     455   
     456    $time = get_moment() - $start;
     457    $count_queries++;
     458   
     459    $output = '';
     460    $output.= '<pre>['.$count_queries.'] '."\n".$query;
     461    $queries_time+= $time;
     462    $output.= "\n".'(this query time : '.number_format( $time, 3, '.', ' ').' s)</b>';
     463    $output.= "\n".'(total SQL time  : '.number_format( $queries_time, 3, '.', ' ').' s)';
     464    $output.= '</pre>';
     465    echo $output;
     466  }
    463467 
    464468  return $result;
Note: See TracChangeset for help on using the changeset viewer.