Ignore:
Timestamp:
Jan 6, 2005, 11:16:21 PM (20 years ago)
Author:
plg
Message:
  • upgrade scripts added for releases 1.3.x
  • my_error function moved from admin/include/functions.php to include/functions.inc.php
  • because MySQL temporary tables are not always authorized on creation, use a temporary table name (with the current microsecond) on a non temporary table (in mass_updates function)
  • ability to retrieve distant full directories (usefull in upgrade scripts)
  • global variables $count_queries and $queries_time moved into global array $page
  • get_cat_display_name displays category names in correct order : the one given by uppercats
  • function setup_style simplified
  • default value for configuration parameter "show_nb_comments" set to false (less queries by default)
File:
1 edited

Legend:

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

    r667 r672  
    487487function pwg_query($query)
    488488{
    489   global $conf,$count_queries,$queries_time;
     489  global $conf,$page;
    490490 
    491491  $start = get_moment();
    492   $result = mysql_query($query);
     492  $result = mysql_query($query) or my_error($query."\n");
    493493 
    494494  $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;
    497504 
    498505  if ($conf['show_queries'])
    499506  {
    500507    $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)';
    504514    $output.= '</pre>';
    505515   
     
    625635  return $src;
    626636}
     637
     638// my_error returns (or send to standard output) the message concerning the
     639// error occured for the last mysql query.
     640function 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}
    627656?>
Note: See TracChangeset for help on using the changeset viewer.