This commit is contained in:
2025-07-09 10:28:20 +08:00
parent ef7e85746d
commit d5c9b3bc86
+17
View File
@@ -84,6 +84,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
{
if ($callback instanceof Query) {
$this->where[] = 'NOT EXISTS(' . $callback->build() . ')';
$this->mergeParams($callback->getParams());
} else {
$this->where[] = 'NOT EXISTS(' . $this->makeClosureFunction($callback) . ')';
}
@@ -104,6 +105,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
{
if ($callback instanceof Query) {
$this->where[] = 'EXISTS(' . $callback->build() . ')';
$this->mergeParams($callback->getParams());
} else {
$this->where[] = 'EXISTS(' . $this->makeClosureFunction($callback) . ')';
}
@@ -302,6 +304,18 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
}
/**
* @param array $params
* @return void
*/
public function mergeParams(array $params): void
{
foreach ($params as $key => $value) {
$this->pushParam($value);
}
}
/**
* @param string $column
* @param callable $callable
@@ -442,6 +456,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
{
if ($tableName instanceof Query) {
$this->from = '(' . $tableName->build() . ')';
$this->mergeParams($tableName->getParams());
} else if ($tableName instanceof Closure) {
$this->from = '(' . $this->makeClosureFunction($tableName) . ')';
} else if (class_exists($tableName)) {
@@ -806,6 +821,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
$this->where[] = $columns . ' IN (' . implode(',', $value) . ')';
} else if ($value instanceof Query) {
$this->where[] = $columns . ' IN (' . $value->build() . ')';
$this->mergeParams($value->getParams());
} else {
$this->where[] = $columns . ' IN (' . $this->makeClosureFunction($value) . ')';
}
@@ -953,6 +969,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
} else {
$generate->addArray($closure);
}
$this->mergeParams($generate->getParams());
return $generate->build();
}