Ticket #10964: 10964.2.diff
File 10964.2.diff, 1.8 KB (added by , 15 years ago) |
---|
-
wp-includes/query.php
2248 2248 $found_rows = ''; 2249 2249 if ( !empty($limits) ) 2250 2250 $found_rows = 'SQL_CALC_FOUND_ROWS'; 2251 2252 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 2251 2252 //////// BELOW CODE MODIFIED BY DAVE BUCHANAN, SPLIT INTO TWO QUERIES ///////////////////// 2253 /// FIRST SELECT JUST IDs 2254 $tmp = " SELECT $distinct $wpdb->posts.id FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 2255 $tmp_q = $wpdb->get_col($tmp); 2256 $tmp_ids = implode($tmp_q,','); 2257 2258 /// NOW NORMAL SELECT WHERE ID IS IN FIRST QUERY LIST 2259 $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE $wpdb->posts.id IN ($tmp_ids) $groupby $orderby "; 2260 2261 ////OLD ONE ///$this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 2262 2253 2263 if ( !$q['suppress_filters'] ) 2254 2264 $this->request = apply_filters('posts_request', $this->request); 2255 2265 … … 2272 2282 } 2273 2283 2274 2284 if ( !empty($limits) ) { 2275 $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 2285 ////OLD ONE///$found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 2286 ////Dave Buchanan Changed below 2287 $found_posts_query = " SELECT $distinct count($wpdb->posts.id) FROM $wpdb->posts $join WHERE 1=1 $where"; 2276 2288 $this->found_posts = $wpdb->get_var( $found_posts_query ); 2277 2289 $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 2278 2290 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);