Changeset 672 for trunk/include/functions.inc.php
- Timestamp:
- Jan 6, 2005, 11:16:21 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r667 r672 487 487 function pwg_query($query) 488 488 { 489 global $conf,$ count_queries,$queries_time;489 global $conf,$page; 490 490 491 491 $start = get_moment(); 492 $result = mysql_query($query) ;492 $result = mysql_query($query) or my_error($query."\n"); 493 493 494 494 $time = get_moment() - $start; 495 $count_queries++; 496 $queries_time+= $time; 495 496 if (!isset($page['count_queries'])) 497 { 498 $page['count_queries'] = 0; 499 $page['queries_time'] = 0; 500 } 501 502 $page['count_queries']++; 503 $page['queries_time']+= $time; 497 504 498 505 if ($conf['show_queries']) 499 506 { 500 507 $output = ''; 501 $output.= '<pre>['.$count_queries.'] '."\n".$query; 502 $output.= "\n".'(this query time : '.number_format( $time, 3, '.', ' ').' s)</b>'; 503 $output.= "\n".'(total SQL time : '.number_format( $queries_time, 3, '.', ' ').' s)'; 508 $output.= '<pre>['.$page['count_queries'].'] '; 509 $output.= "\n".$query; 510 $output.= "\n".'(this query time : '; 511 $output.= number_format($time, 3, '.', ' ').' s)</b>'; 512 $output.= "\n".'(total SQL time : '; 513 $output.= number_format($page['queries_time'], 3, '.', ' ').' s)'; 504 514 $output.= '</pre>'; 505 515 … … 625 635 return $src; 626 636 } 637 638 // my_error returns (or send to standard output) the message concerning the 639 // error occured for the last mysql query. 640 function my_error($header, $echo = true) 641 { 642 $error = '<pre>'; 643 $error.= $header; 644 $error.= '[mysql error '.mysql_errno().'] '; 645 $error.= mysql_error(); 646 $error.= '</pre>'; 647 if ($echo) 648 { 649 echo $error; 650 } 651 else 652 { 653 return $error; 654 } 655 } 627 656 ?>
Note: See TracChangeset
for help on using the changeset viewer.