Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! empty($groupby) )
- $groupby = 'GROUP BY ' . $groupby;
- if ( !empty( $orderby ) )
- $orderby = 'ORDER BY ' . $orderby;
- $found_rows = '';
- // if ( !empty($limits) )
- // $found_rows = 'SQL_CALC_FOUND_ROWS';
- // $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
- $request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
- $this->request = apply_filters('posts_request', $request);
- $this->posts = $wpdb->get_results($this->request);
- // Raw results filter. Prior to status checks.
- $this->posts = apply_filters('posts_results', $this->posts);
- if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
- $cjoin = apply_filters('comment_feed_join', '');
- $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'");
- $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss');
- $this->comments = $wpdb->get_results($comments_request);
- $this->comment_count = count($this->comments);
- }
- if ( !empty($limits) ) {
- // $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
- $count="$distinct $fields"; $first=strpos($count,','); if ($first!==false) {$count=substr($count,0,$first-1);}
- $found_posts_query = " SELECT count($count) FROM $wpdb->posts $join WHERE 1=1 $where $groupby";
- $this->found_posts = $wpdb->get_var( $found_posts_query );
- $this->found_posts = apply_filters( 'found_posts', $this->found_posts );
- $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement