We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to fetch a set of unique activities from Stream DB with wp_stream_get_instance()->db->get_records().
wp_stream_get_instance()->db->get_records()
It turns out, we have no facilities to set a SELECT DISTINCT clause in https://github.com/xwp/stream/blob/3.8.2/classes/class-query.php, in the spirit of https://developer.wordpress.org/reference/hooks/posts_distinct/
SELECT DISTINCT
We probably should have such, right?
EDIT current workaround
/** * Custom SELECT DISTINCT query implementation. * * @see https://github.com/xwp/stream/issues/1301 */ add_filter( 'wp_stream_db_query', static function( string $query, array $args ): string { // @see https://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match if ( isset( $args['_cxl_select_distinct'] ) ) { $query = substr_replace( $query, 'SELECT DISTINCT', (int) strpos( $query, 'SELECT' ), strlen( 'SELECT' ) ); } return $query; }, 10, 2 );
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Feature Request
I'm trying to fetch a set of unique activities from Stream DB with
wp_stream_get_instance()->db->get_records()
.It turns out, we have no facilities to set a
SELECT DISTINCT
clause in https://github.com/xwp/stream/blob/3.8.2/classes/class-query.php, in the spirit of https://developer.wordpress.org/reference/hooks/posts_distinct/We probably should have such, right?
EDIT current workaround
The text was updated successfully, but these errors were encountered: