diff --git a/Database/SqlBuilder.php b/Database/SqlBuilder.php index 406f4267..0860f5aa 100644 --- a/Database/SqlBuilder.php +++ b/Database/SqlBuilder.php @@ -44,6 +44,17 @@ class SqlBuilder extends Component } + /** + * @param array $compiler + * @return string + * @throws Exception + */ + public function hashCompiler(array $compiler): string + { + return $this->where($compiler); + } + + /** * @param array $attributes * @return bool|array @@ -97,7 +108,6 @@ class SqlBuilder extends Component } - /** * @param array $attributes * @param false $isBatch diff --git a/Database/Traits/QueryTrait.php b/Database/Traits/QueryTrait.php index 6cac5c01..efa1a7ca 100644 --- a/Database/Traits/QueryTrait.php +++ b/Database/Traits/QueryTrait.php @@ -816,12 +816,16 @@ trait QueryTrait * @return $this * @throws NotFindClassException * @throws ReflectionException + * @throws Exception */ public function where(Closure|array $conditions): static { if ($conditions instanceof Closure) { $conditions = $this->makeClosureFunction($conditions); } + if (is_array($conditions)) { + $conditions = $this->builder->hashCompiler($conditions); + } $this->where[] = $conditions; return $this; }