public function __toDQL(IcingaDoctrine_Query $q, $dqlOnly = false) { $field = $this->getField(); $value = $this->getValue(); $match = $this->getMatch(); if ($match == IcingaApiConstants::MATCH_LIKE || $match == IcingaApiConstants::MATCH_NOT_LIKE) { $value = str_replace("*", "%", $value); } if (strtolower($q->getConnection()->getDriverName()) == "oracle") { $value = str_replace("'", "''", $value); } else { $value = preg_replace("/'/", "\\'", $value); } $field = preg_replace("/(.*?) +AS +.+ */i", "\$1", $field); $statementSkeleton = $field . " " . $match . " '" . $value . "' "; return $statementSkeleton; }
/** * Applies this filter to a IcingaDoctrine_Query or exports it (depending * if the $dqlOnly is set) * * @param IcingaDoctrine_Query The query to apply this filter to * @param Boolean True to only return the dql * * * @author Jannis Moßhammer <*****@*****.**> **/ public function __toDQL(IcingaDoctrine_Query $q, $dqlOnly) { $connection = $q->getConnection(); $v = $this->formatValues($connection); $dql = $connection->quoteIdentifier($this->field) . " " . $this->operator; if (is_array($v)) { $dql .= " (" . implode(",", $v) . ")"; } else { $dql .= " " . $v; } if ($dqlOnly) { return $dql; } else { $q->where($dql); } return; }