WP_Comment_Query::get_search_sql( string $string, array $cols )

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


Description Description


Parameters Parameters

$string

(string) (Required)

$cols

(array) (Required)


Top ↑

Return Return

(string)


Top ↑

Source Source

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

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

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

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

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

Top ↑

Changelog Changelog

Changelog
Version Description
3.1.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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