/** * Builds a pattern matching string. * * EXPERIMENTAL * * WARNING: this function is experimental and may change signature at * any time until labelled as non-experimental. * * @param array $pattern even keys are strings, odd are patterns (% and _) * @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future) * @param string $field optional field name that is being matched against * (might be required when emulating ILIKE) * * @return string SQL pattern * @override */ public function getMatchPatternExpression($pattern, $operator = null, $field = null) { $match = ''; if (!is_null($operator)) { $field = is_null($field) ? '' : $field . ' '; $operator = strtoupper($operator); switch ($operator) { // case insensitive case 'ILIKE': $match = $field . 'LIKE '; break; // case sensitive // case sensitive case 'LIKE': $match = $field . 'LIKE BINARY '; break; default: throw DoctrineException::operatorNotSupported($operator); } } $match .= "'"; foreach ($pattern as $key => $value) { if ($key % 2) { $match .= $value; } else { $match .= $this->conn->escapePattern($this->conn->escape($value)); } } $match .= "'"; $match .= $this->patternEscapeString(); return $match; }