Compare commits

...

1 Commits

Author SHA1 Message Date
as2252258 ed22201bef eee 2024-07-02 21:38:30 +08:00
2 changed files with 19 additions and 14 deletions
+3 -2
View File
@@ -221,10 +221,11 @@ interface ActiveQueryInterface
public function whereNotBetween(string $column, int|float $start, int|float $end): QueryTrait; 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 * @return QueryTrait
*/ */
public function where(array $column): QueryTrait; public function where(array|string $column, mixed $value = null): QueryTrait;
/** /**
+16 -12
View File
@@ -27,20 +27,20 @@ use Kiri\Abstracts\Component;
*/ */
abstract class QueryTrait extends Component implements ActiveQueryInterface, ISqlBuilder abstract class QueryTrait extends Component implements ActiveQueryInterface, ISqlBuilder
{ {
public array $where = []; protected array $where = [];
public array $select = ['*']; protected array $select = ['*'];
public array $join = []; protected array $join = [];
public array $order = []; protected array $order = [];
public int $offset = -1; protected int $offset = -1;
public int $limit = -1; protected int $limit = -1;
public string $group = ''; protected string $group = '';
public string $from = ''; protected string $from = '';
public string $alias = 't1'; protected string $alias = 't1';
protected array $filter = []; protected array $filter = [];
protected bool $lock = false; protected bool $lock = false;
protected SqlBuilder $builder; protected SqlBuilder $builder;
public array $params = []; protected array $params = [];
private array $_alias = ['t1']; protected array $_alias = ['t1'];
/** /**
@@ -623,10 +623,14 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
/** /**
* @param array|string $column * @param array|string $column
* @param mixed $value
* @return $this * @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)) { if (is_string($column)) {
return $this->whereRaw($column); return $this->whereRaw($column);
} else { } else {