Bp_Search_Activity_Comment::sql( $search_term, $only_totalrow_count = false )
Description
Source
File: bp-search/classes/class-bp-search-activity-comments.php
function sql( $search_term, $only_totalrow_count=false ){ /** * SELECT DISTINCT a.id * FROM wp_bp_activity a * WHERE * a.is_spam = 0 * AND a.content LIKE '%nothing%' * AND a.hide_sitewide = 0 * AND a.type NOT IN ('activity_comment', 'last_activity') * * ORDER BY a.date_recorded DESC LIMIT 0, 21 */ global $wpdb, $bp; $query_placeholder = array(); $sql = " SELECT "; if( $only_totalrow_count ){ $sql .= " COUNT( DISTINCT id ) "; } else { $sql .= " DISTINCT a.id , 'activity_comment' as type, a.content LIKE %s AS relevance, a.date_recorded as entry_date "; $query_placeholder[] = '%'.$wpdb->esc_like( $search_term ).'%'; } //searching only activity updates, others don't make sense $sql .= " FROM {$bp->activity->table_name} a WHERE 1=1 AND is_spam = 0 AND a.content LIKE %s AND a.hide_sitewide = 0 AND a.type = 'activity_comment' "; $query_placeholder[] = '%'.$wpdb->esc_like( $search_term ).'%'; $sql = $wpdb->prepare( $sql, $query_placeholder ); return apply_filters( 'Bp_Search_Activity_Comment_sql', $sql, array( 'search_term' => $search_term, 'only_totalrow_count' => $only_totalrow_count, ) ); }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.