AnsPress_Reputation_Query::query()
Description #
Prepare and fetch reputations from database.
Source #
File: includes/reputation.php
private function query() {
global $wpdb;
$order = 'DESC' === $this->args['order'] ? 'DESC' : 'ASC';
$excluded = sanitize_comma_delimited( $this->with_zero_points, 'str' );
$not_in = '';
if ( ! empty( $excluded ) ) {
$not_in = " AND rep_event NOT IN({$excluded})";
}
$query = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS * FROM {$wpdb->ap_reputations} WHERE rep_user_id = %d{$not_in} ORDER BY rep_date {$order} LIMIT %d,%d", $this->args['user_id'], $this->offset, $this->per_page ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$result = $wpdb->get_results( $query ); // phpcs:ignore WordPress.DB
$this->total_count = $wpdb->get_var( apply_filters( 'ap_reputations_found_rows', 'SELECT FOUND_ROWS()', $this ) ); // phpcs:ignore WordPress.DB
$this->reputations = $result;
$this->total_pages = ceil( $this->total_count / $this->per_page );
$this->count = count( $result );
$this->prefetch();
}
Expand full source code Collapse full source code View on GitHub: includes/reputation.php:672
Add your comment