WP_Network_Query::get_search_sql( string $search, string[] $columns ): string

Used internally to generate an SQL string for searching across multiple columns.


Parameters

$search string Required
Search string.
$columns string[] Required
Array of columns to search.

Top ↑

Return

string Search SQL.


Top ↑

Source

File: wp-includes/class-wp-network-query.php. View all references

protected function get_search_sql( $search, $columns ) {
	global $wpdb;

	$like = '%' . $wpdb->esc_like( $search ) . '%';

	$searches = array();
	foreach ( $columns as $column ) {
		$searches[] = $wpdb->prepare( "$column LIKE %s", $like );
	}

	return '(' . implode( ' OR ', $searches ) . ')';
}


Top ↑

Changelog

Changelog
Version Description
4.6.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.