diff --git a/src/Syntax/Where.php b/src/Syntax/Where.php index 7ed6c5c..90880a8 100644 --- a/src/Syntax/Where.php +++ b/src/Syntax/Where.php @@ -10,9 +10,9 @@ namespace NilPortugues\Sql\QueryBuilder\Syntax; -use NilPortugues\Sql\QueryBuilder\Manipulation\QueryInterface; use NilPortugues\Sql\QueryBuilder\Manipulation\QueryException; use NilPortugues\Sql\QueryBuilder\Manipulation\QueryFactory; +use NilPortugues\Sql\QueryBuilder\Manipulation\QueryInterface; use NilPortugues\Sql\QueryBuilder\Manipulation\Select; /** @@ -29,7 +29,9 @@ class Where const OPERATOR_EQUAL = '='; const OPERATOR_NOT_EQUAL = '<>'; const CONJUNCTION_AND = 'AND'; + const CONJUNCTION_AND_NOT = 'AND NOT'; const CONJUNCTION_OR = 'OR'; + const CONJUNCTION_OR_NOT = 'OR NOT'; const CONJUNCTION_EXISTS = 'EXISTS'; const CONJUNCTION_NOT_EXISTS = 'NOT EXISTS'; @@ -149,6 +151,29 @@ public function getConjunction() return $this->conjunction; } + /** + * @param string $operator + * + * @return $this + * + * @throws QueryException + */ + public function conjunction($operator) + { + if (false === \in_array( + $operator, + [self::CONJUNCTION_AND, self::CONJUNCTION_OR, self::CONJUNCTION_OR_NOT, self::CONJUNCTION_AND_NOT] + ) + ) { + throw new QueryException( + "Invalid conjunction specified, must be one of AND or OR, but '".$operator."' was found." + ); + } + $this->conjunction = $operator; + + return $this; + } + /** * @return array */ @@ -174,25 +199,6 @@ public function subWhere($operator = 'OR') return $filter; } - /** - * @param string $operator - * - * @return $this - * - * @throws QueryException - */ - public function conjunction($operator) - { - if (false === \in_array($operator, [self::CONJUNCTION_AND, self::CONJUNCTION_OR])) { - throw new QueryException( - "Invalid conjunction specified, must be one of AND or OR, but '".$operator."' was found." - ); - } - $this->conjunction = $operator; - - return $this; - } - /** * @return Table */ @@ -218,7 +224,7 @@ public function setTable($table) /** * equals alias. * - * @param $column + * @param $column * @param int $value * * @return static @@ -240,8 +246,8 @@ public function equals($column, $value) } /** - * @param $column - * @param $value + * @param $column + * @param $value * @param string $operator * * @return $this @@ -333,7 +339,7 @@ public function lessThanOrEqual($column, $value) /** * @param string $column - * @param $value + * @param $value * * @return static */ @@ -509,6 +515,14 @@ public function exists(Select $select) return $this; } + /** + * @return array + */ + public function getExists() + { + return $this->exists; + } + /** * @param Select $select * @@ -521,6 +535,14 @@ public function notExists(Select $select) return $this; } + /** + * @return array + */ + public function getNotExists() + { + return $this->notExists; + } + /** * @return array */ @@ -584,20 +606,4 @@ public function getNull() { return $this->isNull; } - - /** - * @return array - */ - public function getExists() - { - return $this->exists; - } - - /** - * @return array - */ - public function getNotExists() - { - return $this->notExists; - } }