Pinq\Expressions\BinaryOperationExpression::update PHP Méthode

update() public méthode

public update ( Expression $leftOperand, integer $operator, Expression $rightOperand ) : self
$leftOperand Expression
$operator integer
$rightOperand Expression
Résultat self
    public function update(Expression $leftOperand, $operator, Expression $rightOperand)
    {
        if ($this->leftOperand === $leftOperand && $this->operator === $operator && $this->rightOperand === $rightOperand) {
            return $this;
        }
        return new self($leftOperand, $operator, $rightOperand);
    }

Usage Example

 protected function visitBinaryOperation(O\BinaryOperationExpression $expression)
 {
     $operator = $expression->getOperator();
     switch ($operator) {
         case Operators\Binary::INEQUALITY:
             $this->walk(O\Expression::unaryOperation(Operators\Unary::NOT, $expression->update($expression->getLeftOperand(), Operators\Binary::EQUALITY, $expression->getRightOperand())));
             return;
         case Operators\Binary::CONCATENATION:
             $this->sql .= 'CONCAT(';
             $this->walk($expression->getLeftOperand());
             $this->sql .= ', ';
             $this->walk($expression->getRightOperand());
             $this->sql .= ')';
             return;
     }
     if (!isset($this->binaryOperators[$operator])) {
         throw new PinqDemoSqlException("Binary operator not supported: {$operator}");
     }
     $this->sql .= '(';
     $this->walk($expression->getLeftOperand());
     $this->sql .= ' ';
     $this->sql .= $this->binaryOperators[$operator];
     $this->sql .= ' ';
     $this->walk($expression->getRightOperand());
     $this->sql .= ')';
 }