+ if ( $count )
+ $fields = 'COUNT(*)';
+ else
+ $fields = '*';
+
+ $join = '';
+ $where = $approved;
+
+ if ( ! empty($post_id) )
+ $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
+ if ( '' !== $author_email )
+ $where .= $wpdb->prepare( ' AND comment_author_email = %s', $author_email );
+ if ( '' !== $karma )
+ $where .= $wpdb->prepare( ' AND comment_karma = %d', $karma );
+ if ( 'comment' == $type ) {
+ $where .= " AND comment_type = ''";
+ } elseif( 'pings' == $type ) {
+ $where .= ' AND comment_type IN ("pingback", "trackback")';
+ } elseif ( ! empty( $type ) ) {
+ $where .= $wpdb->prepare( ' AND comment_type = %s', $type );
+ }
+ if ( '' !== $parent )
+ $where .= $wpdb->prepare( ' AND comment_parent = %d', $parent );
+ if ( '' !== $user_id )
+ $where .= $wpdb->prepare( ' AND user_id = %d', $user_id );
+ if ( '' !== $search )
+ $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );