Changeset 243


Ignore:
Timestamp:
Jan 3, 2004, 8:47:36 PM (20 years ago)
Author:
z0rglub
Message:

add functions pwg_write_debug, pwg_debug, pwg_query

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/include/functions.inc.php

    r141 r243  
    424424  }
    425425}
     426
     427function pwg_write_debug()
     428{
     429  global $debug;
     430 
     431  $fp = @fopen( './log/debug.log', 'a+' );
     432  fwrite( $fp, "\n\n" );
     433  fwrite( $fp, $debug );
     434  fclose( $fp );
     435}
     436
     437function pwg_query( $query )
     438{
     439  global $count_queries,$queries_time;
     440
     441  $start = get_moment();
     442  $output = '';
     443 
     444  $count_queries++;
     445  $output.= '<br /><br />['.$count_queries.'] '.$query;
     446  $result = mysql_query( $query );
     447  $time = get_moment() - $start;
     448  $queries_time+= $time;
     449  $output.= '<b>('.number_format( $time, 3, '.', ' ').' s)</b>';
     450  $output.= '('.number_format( $queries_time, 3, '.', ' ').' s)';
     451
     452  // echo $output;
     453 
     454  return $result;
     455}
     456
     457function pwg_debug( $string )
     458{
     459  global $debug,$t2,$count_queries;
     460
     461  $now = explode( ' ', microtime() );
     462  $now2 = explode( '.', $now[0] );
     463  $now2 = $now[1].'.'.$now2[1];
     464  $time = number_format( $now2 - $t2, 3, '.', ' ').' s';
     465  $debug.= '['.$time.', ';
     466  $debug.= $count_queries.' queries] : '.$string;
     467  $debug.= "\n";
     468}
    426469?>
Note: See TracChangeset for help on using the changeset viewer.