Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/HireVoice/Neo4j/Annotation/ManyToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ class ManyToMany
public $writeOnly = false;
public $relation = null;
public $direction = 'from';

}

27 changes: 26 additions & 1 deletion lib/HireVoice/Neo4j/Query/Cypher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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
*/
Expand Down