- Timestamp:
- Apr 26, 2008, 1:39:06 AM (17 years ago)
- Location:
- branches/branch-1_7
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/include/functions.inc.php
r2220 r2310 534 534 } 535 535 536 // here we ask the database the current date and time, and we extract537 // {year, month, day} from the current date. We could do this during the538 // insert query with a CURDATE(), CURTIME(), DATE_FORMAT(CURDATE(), '%Y')539 // ... but I (plg) think it would cost more than a double query and a PHP540 // extraction.541 $query = '542 SELECT CURDATE(), CURTIME()543 ;';544 list($curdate, $curtime) = mysql_fetch_row(pwg_query($query));545 546 list($curyear, $curmonth, $curday) = explode('-', $curdate);547 list($curhour) = explode(':', $curtime);548 549 536 $query = ' 550 537 INSERT INTO '.HISTORY_TABLE.' … … 566 553 VALUES 567 554 ( 568 \''.$curdate.'\',569 \''.$curtime.'\',570 '.$curyear.',571 '.$curmonth.',572 '.$curday.',573 '.$curhour.',555 CURDATE(), 556 CURTIME(), 557 YEAR( CURDATE() ), 558 MONTH( CURDATE() ), 559 DAYOFMONTH( CURDATE() ), 560 HOUR( CURTIME() ), 574 561 '.$user['id'].', 575 562 \''.$_SERVER['REMOTE_ADDR'].'\', -
branches/branch-1_7/include/functions_tag.inc.php
r1900 r2310 54 54 'visible_images' => 'image_id' 55 55 ), 56 'WHERE' 57 ); 56 ' 57 WHERE' 58 ).' 59 GROUP BY tag_id 60 ORDER BY NULL'; 61 $tag_counters = simple_hash_from_query($query, 'tag_id', 'counter'); 58 62 59 63 if (!empty($where_tag_img)) … … 261 265 ORDER BY counter DESC 262 266 LIMIT 0,'.$max_tags; 267 } 268 else 269 { 270 $query .= ' 271 ORDER BY NULL'; 263 272 } 264 273 -
branches/branch-1_7/include/picture_rate.inc.php
r2202 r2310 33 33 if ($conf['rate']) 34 34 { 35 $query = ' 35 if ( NULL != $picture['current']['average_rate'] ) 36 { 37 $query = ' 36 38 SELECT COUNT(rate) AS count 37 39 , ROUND(AVG(rate),2) AS average … … 40 42 WHERE element_id = '.$picture['current']['id'].' 41 43 ;'; 42 $row = mysql_fetch_array(pwg_query($query)); 44 $row = mysql_fetch_array(pwg_query($query)); 45 } 46 else 47 { // avg rate null -> no rate -> no need to query db 48 $row = array( 'count'=>0, 'average'=>NULL, 'std'=>NULL ); 49 } 50 43 51 if ($row['count'] == 0) 44 52 { -
branches/branch-1_7/picture.php
r2203 r2310 771 771 $template->assign_vars($infos); 772 772 773 773 774 // related categories 774 foreach ($related_categories as $category) 775 { 775 if ( count($related_categories)==1 and 776 isset($page['category']) and 777 $related_categories[0]['category_id']==$page['category']['id'] ) 778 { // no need to go to db, we have all the info 776 779 $template->assign_block_vars( 777 'category', 778 array( 779 'LINE' => count($related_categories) > 3 780 ? get_cat_display_name_cache($category['uppercats']) 781 : get_cat_display_name_from_id($category['category_id']) 782 ) 783 ); 780 'category', 781 array('LINE'=>get_cat_display_name( $page['category']['upper_names'] )) 782 ); 783 } 784 else 785 { // use only 1 sql query to get names for all related categories 786 $ids = array(); 787 foreach ($related_categories as $category) 788 {// add all uppercats to $ids 789 $ids = array_merge($ids, explode(',', $category['uppercats']) ); 790 } 791 $ids = array_unique($ids); 792 $query = ' 793 SELECT id, name, permalink 794 FROM '.CATEGORIES_TABLE.' 795 WHERE id IN ('.implode(',',$ids).')'; 796 $cat_map = hash_from_query($query, 'id'); 797 foreach ($related_categories as $category) 798 { 799 $cats = array(); 800 foreach ( explode(',', $category['uppercats']) as $id ) 801 { 802 $cats[] = $cat_map[$id]; 803 } 804 $template->assign_block_vars('category', array('LINE'=>get_cat_display_name($cats) ) ); 805 } 784 806 } 785 807
Note: See TracChangeset
for help on using the changeset viewer.