/** * @param $alias * @param $property * @param $value * @param string $operator * * @return string * * @throws NotImplementedException if the storage backend is neither mysql * nor postgres nor sqlite */ private function sqlXpathComparePropertyValue($alias, $property, $value, $operator) { $expression = null; if ($this->platform instanceof MySqlPlatform) { $expression = "EXTRACTVALUE({$alias}.props, 'count(//sv:property[@sv:name=\"" . $property . "\"]/sv:value[text()%s%s]) > 0')"; // mysql does not escape the backslashes for us, while postgres and sqlite do $value = Xpath::escapeBackslashes($value); } elseif ($this->platform instanceof PostgreSqlPlatform) { $expression = "xpath_exists('//sv:property[@sv:name=\"" . $property . "\"]/sv:value[text()%s%s]', CAST({$alias}.props AS xml), " . $this->sqlXpathPostgreSQLNamespaces() . ") = 't'"; } elseif ($this->platform instanceof SqlitePlatform) { $expression = "EXTRACTVALUE({$alias}.props, 'count(//sv:property[@sv:name=\"" . $property . "\"]/sv:value[text()%s%s]) > 0')"; } else { throw new NotImplementedException("Xpath evaluations cannot be executed with '" . $this->platform->getName() . "' yet."); } return sprintf($expression, $this->walkOperator($operator), Xpath::escape($value)); }