* @package Mammut\DB\Sql */ trait BoolPredicates { /** * Compares to idents/values to be equal * * @param mixed $left * left side value * @param mixed $right * right side value * @param string $leftType * iExprValue::TYPE_IDENTIFIER (default) or iExprValue::TYPE_VALUE constant * @param string $rightType * iExprValue::TYPE_IDENTIFIER or iExprValue::TYPE_VALUE constant (default) * @return $this */ public function equalTo($left, $right, $leftType = iExprValue::TYPE_IDENTIFIER, $rightType = iExprValue::TYPE_VALUE) { $this->addPredicate(new Compare($left, iExprBool::OP_EQ, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } /** * Shorthand for equalTo(something, something, iExprValue::TYPE_IDENTIFIER, iExprValue::TYPE_IDENTIFIER) * * @param mixed $left * left side identifier * @param mixed $right * right side identifier * @return $this */ public function equalToIdent($left, $right) { return $this->equalTo($left, $right, iExprValue::TYPE_IDENTIFIER, iExprValue::TYPE_IDENTIFIER); } /** * Compares to idents/values to be different to each other * @param mixed $left * left side value * @param mixed $right * right side value * @param string $leftType * iExprValue::TYPE_IDENTIFIER (default) or iExprValue::TYPE_VALUE constant * @param string $rightType * iExprValue::TYPE_IDENTIFIER or iExprValue::TYPE_VALUE constant (default) * @return $this */ public function notEqualTo($left, $right, $leftType = iExprValue::TYPE_IDENTIFIER, $rightType = iExprValue::TYPE_VALUE) { $this->addPredicate(new Compare($left, iExprBool::OP_NE, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function lessThan($left, $right, $leftType = iExprValue::TYPE_IDENTIFIER, $rightType = iExprValue::TYPE_VALUE) { $this->addPredicate(new Compare($left, iExprBool::OP_LT, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function greaterThan($left, $right, $leftType = iExprValue::TYPE_IDENTIFIER, $rightType = iExprValue::TYPE_VALUE) { $this->addPredicate(new Compare($left, iExprBool::OP_GT, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function lessThanOrEqualTo($left, $right, $leftType = iExprValue::TYPE_IDENTIFIER, $rightType = iExprValue::TYPE_VALUE) { $this->addPredicate(new Compare($left, iExprBool::OP_LTE, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function greaterThanOrEqualTo($left, $right, $leftType = iExprValue::TYPE_IDENTIFIER, $rightType = iExprValue::TYPE_VALUE) { $this->addPredicate(new Compare($left, iExprBool::OP_GTE, $right, $leftType, $rightType), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function like($identifier, $like) { $this->addPredicate(new Like($identifier, $like), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function notLike($identifier, $notLike) { $this->addPredicate(new NotLike($identifier, $notLike), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function literal($literal) { if(!isset($predicate)) $predicate = new Literal($literal); $this->addPredicate($predicate, ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function isNull($identifier) { $this->addPredicate(new IsNull($identifier), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function isNotNull($identifier) { $this->addPredicate(new IsNotNull($identifier), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function in($identifier, $valueSet = null) { $this->addPredicate(new In($identifier, $valueSet), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function notIn($identifier, $valueSet = null) { $this->addPredicate(new NotIn($identifier, $valueSet), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } public function between($identifier, $minValue, $maxValue) { $this->addPredicate(new Between($identifier, $minValue, $maxValue), ($this->nextPredicateCombineOperator) ? : $this->defaultCombination); $this->nextPredicateCombineOperator = null; return $this; } }