eee
This commit is contained in:
+11
-9
@@ -793,20 +793,22 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
|
||||
|
||||
/**
|
||||
* @param string $columns
|
||||
* @param array|Closure $value
|
||||
* @param array|Closure|Query $value
|
||||
*
|
||||
* @return $this
|
||||
* @throws
|
||||
* @throws Exception
|
||||
*/
|
||||
public function whereIn(string $columns, array|Closure $value): static
|
||||
public function whereIn(string $columns, array|Closure|Query $value): static
|
||||
{
|
||||
if ($value instanceof Closure) {
|
||||
$value = $this->makeClosureFunction($value);
|
||||
}
|
||||
if (count($value) < 1) {
|
||||
$value = [-1];
|
||||
}
|
||||
if (is_array($value)) {
|
||||
if (count($value) < 1) throw new Exception('Value must be an not empty array');
|
||||
|
||||
$this->where[] = $columns . ' IN (' . implode(',', $value) . ')';
|
||||
} else if ($value instanceof Query) {
|
||||
$this->where[] = $columns . ' IN (' . $value->build() . ')';
|
||||
} else {
|
||||
$this->where[] = $columns . ' IN (' . $this->makeClosureFunction($value) . ')';
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user