public static function getFieldSearchWhereClause($table, $fields, $params, $use_fulltext = TRUE) {
		if (is_callable('search_get_where_sql')) {
			return search_get_where_sql($table, $fields, $params, $use_fulltext);
		}

		$query = $params['query'];

		// add the table prefix to the fields
		foreach ($fields as $i => $field) {
			if ($table) {
				$fields[$i] = "$table.$field";
			}
		}

		$where = '';

		$search_info = elgg_get_config('search_info');

		// if query is shorter than the min for fts words
		// it's likely a single acronym or similar
		// switch to literal mode
		if (elgg_strlen($query) < $search_info['min_chars']) {
			$likes = array();
			$query = sanitise_string($query);
			foreach ($fields as $field) {
				$likes[] = "$field LIKE '%$query%'";
			}
			$likes_str = implode(' OR ', $likes);
			$where = "($likes_str)";
		} else {
			// if we're not using full text, rewrite the query for bool mode.
			// exploiting a feature(ish) of bool mode where +-word is the same as -word
			if (!$use_fulltext) {
				$query = '+' . str_replace(' ', ' +', $query);
			}

			// if using advanced, boolean operators, or paired "s, switch into boolean mode
			$booleans_used = preg_match("/([\-\+~])([\w]+)/i", $query);
			$advanced_search = (isset($params['advanced_search']) && $params['advanced_search']);
			$quotes_used = (elgg_substr_count($query, '"') >= 2);

			$options = '';
			if (!$use_fulltext || $booleans_used || $advanced_search || $quotes_used) {
				$options = 'IN BOOLEAN MODE';
			}

			$query = sanitise_string($query);

			$fields_str = implode(',', $fields);
			$where = "(MATCH ($fields_str) AGAINST ('$query' $options))";
		}

		return $where;
	}