/** * @test */ public function itShouldCreateWhereObject() { $mockClass = '\\NilPortugues\\Sql\\QueryBuilder\\Manipulation\\QueryInterface'; $query = $this->getMockBuilder($mockClass)->disableOriginalConstructor()->getMock(); $className = '\\NilPortugues\\Sql\\QueryBuilder\\Syntax\\Where'; $this->assertInstanceOf($className, QueryFactory::createWhere($query)); }
/** * @return Where */ protected function filter() { if (!isset($this->where)) { $this->where = QueryFactory::createWhere($this); } return $this->where; }
/** * WHERE constrains used for the ON clause of a (LEFT/RIGHT/INNER/CROSS) JOIN. * * @return Where */ public function joinCondition() { if (!isset($this->joinCondition)) { $this->joinCondition = QueryFactory::createWhere($this->select); } return $this->joinCondition; }
/** * @param $havingOperator * * @throws QueryException * @return Where */ public function having($havingOperator = 'AND') { if (!isset($this->having)) { $this->having = QueryFactory::createWhere($this); } if (!in_array($havingOperator, array(Where::CONJUNCTION_AND, Where::CONJUNCTION_OR))) { throw new QueryException("Invalid conjunction specified, must be one of AND or OR, but '" . $havingOperator . "' was found."); } $this->havingOperator = $havingOperator; return $this->having; }
/** * @param $operator * * @return Where */ public function subWhere($operator = 'OR') { /** @var Where $filter */ $filter = QueryFactory::createWhere($this->query); $filter->conjunction($operator); $filter->setTable($this->getTable()); $this->subWheres[] = $filter; return $filter; }
/** * @param \NilPortugues\Sql\QueryBuilder\Manipulation\Select $first * @param \NilPortugues\Sql\QueryBuilder\Manipulation\Select $second * * @return \NilPortugues\Sql\QueryBuilder\Manipulation\Minus */ public function minus(Select $first, Select $second) { return QueryFactory::createMinus($first, $second); }