Noptin_Subscriber_Query::get_search_sql( string $string, array $cols )
Used internally to generate an SQL string for searching across multiple columns
Parameters Parameters
- $string
(string) (Required) The string to search for.
- $cols
(array) (Required) The columns to search in.
Return Return
(string)
Source Source
File: includes/class-noptin-subscriber-query.php
protected function get_search_sql( $string, $cols ) { global $wpdb; $searches = array(); $string = trim( $string, '%' ); $like = '%' . $wpdb->esc_like( $string ) . '%'; foreach ( $cols as $col ) { if ( 'id' === $col ) { $searches[] = $wpdb->prepare( "$col = %s", $string ); } else { $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); } } return ' AND (' . implode( ' OR ', $searches ) . ')'; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.2.7 | Introduced. |