diff --git a/lib/HireVoice/Neo4j/Annotation/ManyToMany.php b/lib/HireVoice/Neo4j/Annotation/ManyToMany.php index 7bde7ef..13d2000 100644 --- a/lib/HireVoice/Neo4j/Annotation/ManyToMany.php +++ b/lib/HireVoice/Neo4j/Annotation/ManyToMany.php @@ -33,6 +33,5 @@ class ManyToMany public $writeOnly = false; public $relation = null; public $direction = 'from'; - } diff --git a/lib/HireVoice/Neo4j/Query/Cypher.php b/lib/HireVoice/Neo4j/Query/Cypher.php index 37f42bb..383feb4 100644 --- a/lib/HireVoice/Neo4j/Query/Cypher.php +++ b/lib/HireVoice/Neo4j/Query/Cypher.php @@ -26,11 +26,14 @@ use Everyman\Neo4j\Node; use Everyman\Neo4j\Path; use HireVoice\Neo4j\EntityManager; +use Everyman\Neo4j\Cypher\Query as InternalCypherQuery; class Cypher extends Query { const CLAUSE_WHERE = 'where'; + const CLAUSE_ORWHERE = 'or where'; + const CLAUSE_USING = 'using'; const CLAUSE_OPTIONAL_MATCH = 'optional match'; @@ -238,6 +241,11 @@ public function where($string) return $this->appendToQuery(self::CLAUSE_WHERE, func_get_args()); } + public function orWhere($string) + { + return $this->appendToQuery(self::CLAUSE_ORWHERE, func_get_args()); + } + /** * @api * @param string $string @@ -321,13 +329,21 @@ protected function appendToQuery($clause, $args) { switch ($clause) { case self::CLAUSE_WHERE: - if ($this->currentClause !== $clause) { + if ($this->currentClause !== self::CLAUSE_WHERE && $this->currentClause !== self::CLAUSE_ORWHERE) { $this->query .= PHP_EOL . $clause . ' (' . implode(') AND (', $args) . ')'; } else { $this->query .= ' AND (' . implode(') AND (', $args) . ')'; } break; + case self::CLAUSE_ORWHERE: + if ($this->currentClause !== self::CLAUSE_WHERE && $this->currentClause !== self::CLAUSE_ORWHERE) { + $this->query .= PHP_EOL . self::CLAUSE_WHERE . ' (' . implode(') OR (', $args) . ')'; + } else { + $this->query .= ' OR (' . implode(') OR (', $args) . ')'; + } + break; + case self::CLAUSE_USING: case self::CLAUSE_OPTIONAL_MATCH: $this->query .= PHP_EOL . $clause . ' ' . implode(PHP_EOL . $clause . ' ', $args); @@ -351,6 +367,15 @@ protected function appendToQuery($clause, $args) return $this; } + /** + * @return \Everyman\Neo4j\Cypher\Query + */ + public function getQuery() + { + $parameters = $this->processor->process(); + return new InternalCypherQuery($this->em->getClient(), $this->query, $parameters); + } + /** * @return \Everyman\Neo4j\Query\ResultSet */