From d5c9b3bc863fc2b9832639fd6e4910c78e0e25df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 9 Jul 2025 10:28:20 +0800 Subject: [PATCH] eee --- Traits/QueryTrait.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Traits/QueryTrait.php b/Traits/QueryTrait.php index 3732dee..99d29db 100644 --- a/Traits/QueryTrait.php +++ b/Traits/QueryTrait.php @@ -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(); }