This commit is contained in:
2024-12-13 15:03:09 +08:00
parent db92238e9e
commit 42af2e8bf9
+22 -2
View File
@@ -75,8 +75,8 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
/**
* @param Closure|string $callback
* @param array $attributes
* @param Closure|Query $callback
* @param array $attributes
*
* @return $this
*/
@@ -94,6 +94,26 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
}
/**
* @param Closure|Query $callback
* @param array $attributes
*
* @return $this
*/
public function whereExists(Closure|Query $callback, array $attributes = []): static
{
if ($callback instanceof Query) {
$this->where[] = 'EXISTS(' . $callback->build() . ')';
} else {
$this->where[] = 'EXISTS(' . $this->makeClosureFunction($callback) . ')';
}
if (count($attributes) > 0) {
$this->bindParams($attributes);
}
return $this;
}
/**
* @param array $select
*