BP_Activity_Activity::get_in_operator_sql( string $field, array|bool $items )
Create SQL IN clause for filter queries.
Description
See also
Parameters
- $field
-
(Required) The database field.
- $items
-
(Required) The values for the IN clause, or false when none are found.
Return
(string|false)
Source
File: bp-activity/classes/class-bp-activity-activity.php
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 | public static function get_in_operator_sql( $field , $items ) { global $wpdb ; // Split items at the comma. if ( ! is_array ( $items ) ) { $items = explode ( ',' , $items ); } // Array of prepared integers or quoted strings. $items_prepared = array (); // Clean up and format each item. foreach ( $items as $item ) { // Clean up the string. $item = trim( $item ); // Pass everything through prepare for security and to safely quote strings. $items_prepared [] = ( is_numeric ( $item ) ) ? $wpdb ->prepare( '%d' , $item ) : $wpdb ->prepare( '%s' , $item ); } // Build IN operator sql syntax. if ( count ( $items_prepared ) ) return sprintf( '%s IN ( %s )' , trim( $field ), implode( ',' , $items_prepared ) ); else return false; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | Introduced. |
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.