Changeset 26759


Ignore:
Timestamp:
01/15/14 21:00:38 (5 years ago)
Author:
rvelices
Message:

one less expensive query in comments.php (triple table join is already being done and we can use the result)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r26461 r26759  
    373373} 
    374374 
    375 $query = ' 
    376 SELECT COUNT(DISTINCT(com.id)) 
    377   FROM '.IMAGE_CATEGORY_TABLE.' AS ic 
    378     INNER JOIN '.COMMENTS_TABLE.' AS com 
    379     ON ic.image_id = com.image_id 
    380     LEFT JOIN '.USERS_TABLE.' As u 
    381     ON u.'.$conf['user_fields']['id'].' = com.author_id 
    382   WHERE '.implode(' 
    383     AND ', $page['where_clauses']).' 
    384 ;'; 
    385 list($counter) = pwg_db_fetch_row(pwg_query($query)); 
    386  
    387 $url = PHPWG_ROOT_PATH.'comments.php' 
    388   .get_query_string_diff(array('start','edit','delete','validate','pwg_token')); 
    389  
    390 $navbar = create_navigation_bar($url, 
    391                                 $counter, 
    392                                 $start, 
    393                                 $page['items_number'], 
    394                                 ''); 
    395  
    396 $template->assign('navbar', $navbar); 
    397  
    398375// +-----------------------------------------------------------------------+ 
    399376// |                        last comments display                          | 
     
    405382 
    406383$query = ' 
    407 SELECT com.id AS comment_id, 
     384SELECT SQL_CALC_FOUND_ROWS com.id AS comment_id, 
    408385       com.image_id, 
    409386       com.author, 
     
    422399  WHERE '.implode(' 
    423400    AND ', $page['where_clauses']).' 
    424   GROUP BY comment_id, 
    425        com.image_id, 
    426        com.author, 
    427        com.author_id, 
    428        com.date, 
    429        com.content, 
    430        com.validated 
     401  GROUP BY comment_id 
    431402  ORDER BY '.$page['sort_by'].' '.$page['sort_order']; 
    432403if ('all' != $page['items_number']) 
     
    443414  $element_ids[] = $row['image_id']; 
    444415} 
     416list($counter) = pwg_db_fetch_row(pwg_query('SELECT FOUND_ROWS()')); 
     417 
     418$url = PHPWG_ROOT_PATH.'comments.php' 
     419  .get_query_string_diff(array('start','edit','delete','validate','pwg_token')); 
     420 
     421$navbar = create_navigation_bar($url, 
     422                                $counter, 
     423                                $start, 
     424                                $page['items_number'], 
     425                                ''); 
     426 
     427$template->assign('navbar', $navbar); 
     428 
    445429 
    446430if (count($comments) > 0) 
Note: See TracChangeset for help on using the changeset viewer.