Final Class Yiisoft\Db\Pgsql\Builder\CaseXBuilder
| Inheritance | Yiisoft\ |
|---|
Builds expressions for {@see CaseX}.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| build() | Yiisoft\ |
Method Details
| public string build ( \ | ||
| $expression | \ |
The |
| $params | array | |
public function build(ExpressionInterface $expression, array &$params = []): string
{
$sql = 'CASE';
if ($expression->value !== null) {
$caseTypeHint = $this->buildTypeHint($expression->valueType);
$sql .= ' ' . $this->buildCaseValueWithTypeHint($expression->value, $caseTypeHint, $params);
} else {
$caseTypeHint = '';
}
foreach ($expression->whenThen as $whenThen) {
$sql .= ' WHEN ' . $this->buildConditionWithTypeHint($whenThen->when, $caseTypeHint, $params);
$sql .= ' THEN ' . $this->queryBuilder->buildValue($whenThen->then, $params);
}
if ($expression->hasElse()) {
$sql .= ' ELSE ' . $this->queryBuilder->buildValue($expression->else, $params);
}
return $sql . ' END';
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.