$link_ids */ public function count_posts( array $link_ids ): int { $placeholders = array_fill( 0, count( $link_ids ), '%d' ); $query = $this->query_runner->prepare( 'SELECT COUNT(*) FROM (SELECT DISTINCT link_id, post_id FROM ' . $this->tables->uses() . ' WHERE link_id IN (' . implode( ',', $placeholders ) . ')) places', ...$link_ids ); return (int) $this->query_runner->value( $query ); } /** * @param list $handled_post_ids * @return list */ public function pending_posts( int $link_id, array $handled_post_ids ): array { $rows = $this->query_runner->rows( $this->query_runner->prepare( 'SELECT DISTINCT post_id FROM ' . $this->tables->uses() . ' WHERE link_id = %d ORDER BY post_id', $link_id ) ); $post_ids = array(); foreach ( $rows as $row ) { $post_ids[] = RowColumns::whole_number( $row, 'post_id' ); } return array_values( array_diff( $post_ids, $handled_post_ids ) ); } }