Final Class Yiisoft\Db\Expression\Function\Longest
| Inheritance | Yiisoft\Db\Expression\Function\Longest » Yiisoft\Db\Expression\Function\MultiOperandFunction |
|---|---|
| Implements | Yiisoft\Db\Expression\ExpressionInterface |
Represents SQL expression that returns the longest string from a list of operands.
This function compares the lengths of the provided strings or expressions and returns the longest one. If multiple strings have the same maximum length, it returns the first one encountered.
Example usage:
$longest = new Longest(new Value('short'), 'column_name');
See also \Yiisoft\Db\Expression\Function\LongestBuilder for building SQL representations of this function expression.
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $operands | array | List of operands. | Yiisoft\Db\Expression\Function\MultiOperandFunction |
Public Methods
Method Details
| public __construct( mixed $operands ): mixed | ||
| $operands | mixed |
The values or expressions to operate on. String values will be treated as column names,
except when they contain a parentheses |
public function __construct(mixed ...$operands)
{
$this->operands = $operands;
}
| public add( mixed $operand ): Yiisoft\Db\Expression\Function\Longest | ||
| $operand | mixed | |
public function add(mixed $operand): static
{
$this->operands[] = $operand;
return $this;
}
| public getOperands( ): array | ||
| return | array |
List of operands. |
|---|---|---|
public function getOperands(): array
{
return $this->operands;
}
Signup or Login in order to comment.