Changeset 4331


Ignore:
Timestamp:
11/21/09 13:15:22 (10 years ago)
Author:
nikrou
Message:

Feature 1255 : improve sql
Replace in queries LIMIT N,M by LIMIT N OFFSET M

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_perm.php

    r4325 r4331  
    6060  FROM '.CATEGORIES_TABLE.' 
    6161  WHERE status = \'private\' 
    62   LIMIT 0,1 
     62  LIMIT 0 OFFSET 1 
    6363;'; 
    6464 
  • trunk/admin/element_set_global.php

    r4325 r4331  
    475475  WHERE id IN ('.implode(',', $page['cat_elements_id']).') 
    476476  '.$conf['order_by'].' 
    477   LIMIT '.$page['start'].', '.$page['nb_images'].' 
     477  LIMIT '.$page['start'].' OFFSET '.$page['nb_images'].' 
    478478;'; 
    479479  //echo '<pre>'.$query.'</pre>'; 
  • trunk/admin/element_set_unit.php

    r4325 r4331  
    197197  WHERE id IN ('.implode(',', $page['cat_elements_id']).') 
    198198  '.$conf['order_by'].' 
    199   LIMIT '.$page['start'].', '.$page['nb_images'].' 
     199  LIMIT '.$page['start'].' OFFSET '.$page['nb_images'].' 
    200200;'; 
    201201  $result = pwg_query($query); 
  • trunk/admin/include/functions.php

    r4325 r4331  
    597597  FROM '.IMAGE_CATEGORY_TABLE.' 
    598598  WHERE category_id = '.$category_id.' 
    599   ORDER BY RAND() 
    600   LIMIT 0,1 
     599  ORDER BY '.DB_RANDOM_FUNCTION.'() 
     600  LIMIT 0 OFFSET 1 
    601601;'; 
    602602    list($representative) = pwg_db_fetch_row(pwg_query($query)); 
  • trunk/admin/include/functions_history.inc.php

    r4325 r4331  
    162162;'; 
    163163 
    164   // LIMIT '.$page['start'].', '.$conf['nb_logs_page'].' 
     164  // LIMIT '.$page['start'].' OFFSET '.$conf['nb_logs_page'].' 
    165165 
    166166  $result = pwg_query($query); 
  • trunk/admin/rating.php

    r4325 r4331  
    177177  GROUP BY r.element_id 
    178178  ORDER BY ' . $available_order_by[$order_by_index][1] .' 
    179   LIMIT '.$start.','.$elements_per_page.' 
     179  LIMIT '.$start.' OFFSET '.$elements_per_page.' 
    180180;'; 
    181181 
  • trunk/comments.php

    r4325 r4331  
    327327{ 
    328328  $query.= ' 
    329   LIMIT '.$start.','.$page['items_number']; 
     329  LIMIT '.$start.' OFFSET '.$page['items_number']; 
    330330} 
    331331$query.= ' 
  • trunk/include/calendar_monthly.class.php

    r4325 r4331  
    349349    $query.= ' 
    350350  ORDER BY RAND() 
    351   LIMIT 0,1'; 
     351  LIMIT 0 OFFSET 1'; 
    352352    unset ( $page['chronology_date'][CDAY] ); 
    353353 
  • trunk/include/functions_notification.inc.php

    r4325 r4331  
    445445  GROUP BY date_available 
    446446  ORDER BY date_available DESC 
    447   LIMIT 0,'.$max_dates.' 
     447  LIMIT 0 OFFSET '.$max_dates.' 
    448448;'; 
    449449  $result = pwg_query($query); 
     
    465465    AND tn_ext IS NOT NULL 
    466466  ORDER BY RAND(NOW()) 
    467   LIMIT 0,'.$max_elements.' 
     467  LIMIT 0 OFFSET '.$max_elements.' 
    468468;'; 
    469469      $dates[$i]['elements'] = array(); 
     
    485485  GROUP BY category_id 
    486486  ORDER BY img_count DESC 
    487   LIMIT 0,'.$max_cats.' 
     487  LIMIT 0 OFFSET '.$max_cats.' 
    488488;'; 
    489489      $dates[$i]['categories'] = array(); 
  • trunk/include/picture_comment.inc.php

    r4325 r4331  
    137137$validated_clause.' 
    138138  ORDER BY date ASC 
    139   LIMIT '.$page['start'].', '.$conf['nb_comment_page'].' 
     139  LIMIT '.$page['start'].' OFFSET '.$conf['nb_comment_page'].' 
    140140;'; 
    141141    $result = pwg_query( $query ); 
  • trunk/include/ws_functions.inc.php

    r4325 r4331  
    293293GROUP BY i.id 
    294294'.$order_by.' 
    295 LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page']; 
     295LIMIT '.(int)($params['per_page']*$params['page']).' OFFSET '.(int)$params['per_page']; 
    296296 
    297297    $result = pwg_query($query); 
     
    684684  ORDER BY date 
    685685  LIMIT '.(int)($params['comments_per_page']*$params['comments_page']). 
    686     ','.(int)$params['comments_per_page']; 
     686    ' OFFSET '.(int)$params['comments_per_page']; 
    687687 
    688688    $result = pwg_query($query); 
     
    13991399    AND ', $where_clauses).' 
    14001400'.$order_by.' 
    1401 LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page']; 
     1401LIMIT '.(int)($params['per_page']*$params['page']).' OFFSET '.(int)$params['per_page']; 
    14021402 
    14031403    $result = pwg_query($query); 
Note: See TracChangeset for help on using the changeset viewer.