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

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


Description Description


Parameters Parameters

$string

(string) (Required) Search string.

$columns

(string[]) (Required) Array of columns to search.


Top ↑

Return Return

(string) Search SQL.


Top ↑

Source Source

File: wp-includes/class-wp-network-query.php

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

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

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

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

Top ↑

Changelog Changelog

Changelog
Version Description
4.6.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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