Final Class Yiisoft\Db\Oracle\Builder\ArrayMergeBuilder
| Inheritance | Yiisoft\Db\Oracle\Builder\ArrayMergeBuilder » Yiisoft\Db\Expression\Function\Builder\MultiOperandFunctionBuilder |
|---|
Builds SQL expressions which merge arrays for {@see ArrayMerge} objects.
(SELECT JSON_ARRAYAGG(value) AS value FROM (
SELECT value FROM JSON_TABLE(operand1, '$[*]' COLUMNS(value int PATH '$'))
UNION
SELECT value FROM JSON_TABLE(operand2, '$[*]' COLUMNS(value int PATH '$'))
))
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| buildFromExpression() | Builds a SQL expression which merges arrays from the given {@see ArrayMerge} object. | Yiisoft\Db\Oracle\Builder\ArrayMergeBuilder |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| DEFAULT_OPERAND_TYPE | '' | Yiisoft\Db\Oracle\Builder\ArrayMergeBuilder |
Method Details
Builds a SQL expression which merges arrays from the given {@see ArrayMerge} object.
| protected string buildFromExpression ( \Yiisoft\Db\Expression\Function\ArrayMerge $expression, array &$params ) | ||
| $expression | \Yiisoft\Db\Expression\Function\ArrayMerge |
The expression to build. |
| $params | array |
The parameters to bind. |
| return | string |
The SQL expression. |
|---|---|---|
protected function buildFromExpression(MultiOperandFunction $expression, array &$params): string
{
$selects = [];
$operandType = $this->buildOperandType($expression->getType());
foreach ($expression->getOperands() as $operand) {
$builtOperand = $this->buildOperand($operand, $params);
$selects[] = "SELECT value FROM JSON_TABLE($builtOperand, '$[*]' COLUMNS(value $operandType PATH '$'))";
}
$orderBy = $expression->getOrdered() ? ' ORDER BY value' : '';
$unions = implode(' UNION ', $selects);
return "(SELECT JSON_ARRAYAGG(value$orderBy) AS value FROM ($unions))";
}
Signup or Login in order to comment.