GC_Comment_Query::get_search_sql()

最后更新于:2021-11-26 22:39:19

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

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

参数

$string

(string) (Required)

$cols

(array) (Required)

响应

(string)

源文件

文件: gc-includes/class-gc-comment-query.php

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

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

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

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