0 follower

Final Class Yiisoft\Db\Expression\Function\Greatest

InheritanceYiisoft\Db\Expression\Function\Greatest » Yiisoft\Db\Expression\Function\MultiOperandFunction
ImplementsYiisoft\Db\Expression\ExpressionInterface

Represents a SQL GREATEST() function that returns the greatest value from a list of values or expressions.

Example usage:

$greatest = new Greatest(1, '(a + b)', $db->select('column')->from('table')->where(['id' => 1]));
GREATEST(1, (a + b), (SELECT "column" FROM "table" WHERE "id" = 1))

See also Yiisoft\Db\Expression\Function\Builder\GreatestBuilder for building SQL representations of this function expression.

Protected Properties

Hide inherited properties

Property Type Description Defined By
$operands array List of operands. Yiisoft\Db\Expression\Function\MultiOperandFunction

Method Details

Hide inherited methods

__construct() public method
public mixed __construct ( mixed $operands )
$operands mixed

The values or expressions to operate on. String values will be treated as column names, except when they contain a parentheses (, in which case they will be treated as raw SQL expressions.

                public function __construct(mixed ...$operands)
{
    $this->operands = $operands;
}

            
add() public method
public Yiisoft\Db\Expression\Function\Greatest add ( mixed $operand )
$operand mixed

                public function add(mixed $operand): static
{
    $this->operands[] = $operand;
    return $this;
}

            
getOperands() public method
public array getOperands ( )
return array

List of operands.

                public function getOperands(): array
{
    return $this->operands;
}