Final Class Yiisoft\Db\Oracle\Builder\InBuilder
| Inheritance | Yiisoft\Db\Oracle\Builder\InBuilder » Yiisoft\Db\QueryBuilder\Condition\Builder\InBuilder |
|---|
Build an object of {@see In} or {@see NotIn} into SQL expressions for Oracle Server.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| build() | The Method builds the raw SQL from the $expression that won't be additionally escaped or quoted. | Yiisoft\Db\Oracle\Builder\InBuilder |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| splitCondition() | Oracle DBMS doesn't support more than 1000 parameters in IN condition. |
Yiisoft\Db\Oracle\Builder\InBuilder |
Method Details
The Method builds the raw SQL from the $expression that won't be additionally escaped or quoted.
| public string build ( \Yiisoft\Db\QueryBuilder\Condition\In|\Yiisoft\Db\QueryBuilder\Condition\NotIn $expression, array &$params = [] ) | ||
| $expression | \Yiisoft\Db\QueryBuilder\Condition\In|\Yiisoft\Db\QueryBuilder\Condition\NotIn |
The expression to build. |
| $params | array |
The binding parameters. |
| return | string |
The raw SQL that won't be additionally escaped or quoted. |
|---|---|---|
| throws | \Yiisoft\Db\Exception\Exception | |
| throws | InvalidArgumentException | |
| throws | \Yiisoft\Db\Exception\InvalidConfigException | |
| throws | \Yiisoft\Db\Exception\NotSupportedException | |
public function build(ExpressionInterface $expression, array &$params = []): string
{
$splitCondition = $this->splitCondition($expression, $params);
return $splitCondition ?? parent::build($expression, $params);
}
Oracle DBMS doesn't support more than 1000 parameters in IN condition.
This method splits long IN condition into series of smaller ones.
| protected string|null splitCondition ( \Yiisoft\Db\QueryBuilder\Condition\In|\Yiisoft\Db\QueryBuilder\Condition\NotIn $condition, array &$params ) | ||
| $condition | \Yiisoft\Db\QueryBuilder\Condition\In|\Yiisoft\Db\QueryBuilder\Condition\NotIn | |
| $params | array |
The binding parameters. |
| return | string|null |
|
|---|---|---|
| throws | \Yiisoft\Db\Exception\Exception | |
| throws | InvalidArgumentException | |
| throws | \Yiisoft\Db\Exception\InvalidConfigException | |
| throws | \Yiisoft\Db\Exception\NotSupportedException | |
protected function splitCondition(In|NotIn $condition, array &$params): ?string
{
$operator = match ($condition::class) {
In::class => 'IN',
NotIn::class => 'NOT IN',
};
$values = $condition->values;
$column = $condition->column;
if (!is_array($values)) {
return null;
}
$maxParameters = 1000;
$count = count($values);
if ($count <= $maxParameters) {
return null;
}
$slices = [];
for ($i = 0; $i < $count; $i += $maxParameters) {
$slices[] = $this->queryBuilder->createConditionFromArray(
[$operator, $column, array_slice($values, $i, $maxParameters)],
);
}
array_unshift($slices, ($operator === 'IN') ? 'OR' : 'AND');
return $this->queryBuilder->buildCondition($slices, $params);
}
Signup or Login in order to comment.