$ids Ids, in any order. * * @return array{0: int, 1: int, 2: string} */ public static function ids( array $ids ): array { $ids = array_values( array_unique( array_filter( array_map( 'intval', $ids ), static fn( int $id ): bool => $id > 0 ) ) ); if ( array() === $ids ) { return array( 0, 0, '' ); } return array( min( $ids ), max( $ids ), implode( ',', $ids ) ); } /** * A comma-joined set of strings for `FIND_IN_SET( col, %s )`. * * For a column no index could serve anyway — `LOWER( address )` — so there is no range to add. * * A VALUE CONTAINING A COMMA IS DROPPED. MySQL would read it as two members, and matching either * half would be a wrong answer rather than a missing one. * * @param array $values Values, exactly as they should be compared. */ public static function strings( array $values ): string { $values = array_filter( array_unique( array_map( 'strval', $values ) ), static fn( string $value ): bool => '' !== $value && ! str_contains( $value, ',' ) ); return implode( ',', $values ); } }