diff --git a/Base/ActiveQueryInterface.php b/Base/ActiveQueryInterface.php index e0b4588..ebde026 100644 --- a/Base/ActiveQueryInterface.php +++ b/Base/ActiveQueryInterface.php @@ -221,10 +221,11 @@ interface ActiveQueryInterface public function whereNotBetween(string $column, int|float $start, int|float $end): QueryTrait; /** - * @param array $column + * @param array|string $column + * @param mixed|null $value * @return QueryTrait */ - public function where(array $column): QueryTrait; + public function where(array|string $column, mixed $value = null): QueryTrait; /** diff --git a/Traits/QueryTrait.php b/Traits/QueryTrait.php index 8841f08..fb781ad 100644 --- a/Traits/QueryTrait.php +++ b/Traits/QueryTrait.php @@ -27,20 +27,20 @@ use Kiri\Abstracts\Component; */ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISqlBuilder { - public array $where = []; - public array $select = ['*']; - public array $join = []; - public array $order = []; - public int $offset = -1; - public int $limit = -1; - public string $group = ''; - public string $from = ''; - public string $alias = 't1'; + protected array $where = []; + protected array $select = ['*']; + protected array $join = []; + protected array $order = []; + protected int $offset = -1; + protected int $limit = -1; + protected string $group = ''; + protected string $from = ''; + protected string $alias = 't1'; protected array $filter = []; protected bool $lock = false; protected SqlBuilder $builder; - public array $params = []; - private array $_alias = ['t1']; + protected array $params = []; + protected array $_alias = ['t1']; /** @@ -623,10 +623,14 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq /** * @param array|string $column + * @param mixed $value * @return $this */ - public function where(array|string $column): static + public function where(array|string $column, mixed $value = null): static { + if (func_num_args() === 2) { + return $this->addArray([$column => $value]); + } if (is_string($column)) { return $this->whereRaw($column); } else {