Changeset 2308


Ignore:
Timestamp:
Apr 25, 2008, 3:00:39 AM (16 years ago)
Author:
rvelices
Message:
  • minor sql query optimizations
Location:
trunk/include
Files:
2 edited

Legend:

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

    r2299 r2308  
    565565  }
    566566
    567   // here we ask the database the current date and time, and we extract
    568   // {year, month, day} from the current date. We could do this during the
    569   // insert query with a CURDATE(), CURTIME(), DATE_FORMAT(CURDATE(), '%Y')
    570   // ... but I (plg) think it would cost more than a double query and a PHP
    571   // extraction.
    572   $query = '
    573 SELECT CURDATE(), CURTIME()
    574 ;';
    575   list($curdate, $curtime) = mysql_fetch_row(pwg_query($query));
    576 
    577   list($curyear, $curmonth, $curday) = explode('-', $curdate);
    578   list($curhour) = explode(':', $curtime);
    579 
    580567  $query = '
    581568INSERT INTO '.HISTORY_TABLE.'
     
    597584  VALUES
    598585  (
    599     \''.$curdate.'\',
    600     \''.$curtime.'\',
    601     '.$curyear.',
    602     '.$curmonth.',
    603     '.$curday.',
    604     '.$curhour.',
     586    CURDATE(),
     587    CURTIME(),
     588    YEAR( CURDATE() ),
     589    MONTH( CURDATE() ),
     590    DAYOFMONTH( CURDATE() ),
     591    HOUR( CURTIME() ),
    605592    '.$user['id'].',
    606593    \''.$_SERVER['REMOTE_ADDR'].'\',
  • trunk/include/functions_tag.inc.php

    r2299 r2308  
    5050  WHERE'
    5151    ).'
    52   GROUP BY tag_id';
     52  GROUP BY tag_id
     53  ORDER BY NULL';
    5354  $tag_counters = simple_hash_from_query($query, 'tag_id', 'counter');
    5455
     
    243244  ORDER BY counter DESC
    244245  LIMIT 0,'.$max_tags;
     246  }
     247  else
     248  {
     249    $query .= '
     250  ORDER BY NULL';
    245251  }
    246252
Note: See TracChangeset for help on using the changeset viewer.