1 redirect.admin.inc redirect_build_filter_query(SelectQueryInterface $query, array $fields, $keys = '')

Extends a query object for URL redirect filters.

Parameters

QueryAlterableInterface $query: Query object that should be filtered.

array $fields: The fields within the query that should be checked for the $keys value.

string $keys: The filter string on which asterisks should be replaced with

File

core/modules/redirect/redirect.admin.inc, line 217
Administrative page callbacks for the Redirect module.

Code

function redirect_build_filter_query(SelectQueryInterface $query, array $fields, $keys = '') {
  if ($keys && $fields) {
    // Replace wildcards with PDO wildcards.
    $conditions = db_or();
    $wildcard = '%' . trim(preg_replace('!\*+!', '%', db_like($keys)), '%') . '%';
    foreach ($fields as $field) {
      $conditions->condition($field, $wildcard, 'LIKE');
    }
    $query->condition($conditions);
  }
}