This commit is contained in:
2023-12-13 10:05:42 +08:00
parent 013be605f4
commit 16fe127019
6 changed files with 118 additions and 122 deletions
+83 -86
View File
@@ -3,6 +3,7 @@
namespace Database\Base;
use Closure;
use Database\Traits\QueryTrait;
interface ActiveQueryInterface
{
@@ -11,261 +12,257 @@ interface ActiveQueryInterface
/**
* @param string $column
* @param callable $callable
* @return $this
* @return QueryTrait
*/
public function when(string $column, callable $callable): static;
public function when(string $column, callable $callable): QueryTrait;
/**
* @param string $whereRaw
* @return $this
* @return QueryTrait
*/
public function whereRaw(string $whereRaw): static;
public function whereRaw(string $whereRaw): QueryTrait;
/**
* @param string $column
* @param string $value
* @return $this
* @return QueryTrait
*/
public function whereLocate(string $column, string $value): static;
public function whereLocate(string $column, string $value): QueryTrait;
/**
* @param string $column
* @return $this
* @return QueryTrait
*/
public function whereNull(string $column): static;
public function whereNull(string $column): QueryTrait;
/**
* @param string $column
* @return $this
* @return QueryTrait
*/
public function whereEmpty(string $column): static;
public function whereEmpty(string $column): QueryTrait;
/**
* @param string $column
* @return $this
* @return QueryTrait
*/
public function whereNotEmpty(string $column): static;
public function whereNotEmpty(string $column): QueryTrait;
/**
* @param string $column
* @return $this
* @return QueryTrait
*/
public function whereNotNull(string $column): static;
public function whereNotNull(string $column): QueryTrait;
/**
* @param string $alias
*
* @return $this
* @return QueryTrait select * from tableName as t1
*
* select * from tableName as t1
*/
public function alias(string $alias = 't1'): static;
public function alias(string $alias = 't1'): QueryTrait;
/**
* @param string|Closure $tableName
*
* @return $this
* @return QueryTrait
*/
public function from(string|Closure $tableName): static;
public function from(string|Closure $tableName): QueryTrait;
/**
* @param string $tableName
* @param string $alias
* @param $onCondition
* @param null $param
* @return $this
* @throws
* @param string|array $onCondition
* @param array $param
* @return QueryTrait
*/
public function leftJoin(string $tableName, string $alias, $onCondition, $param = NULL): static;
public function leftJoin(string $tableName, string $alias, string|array $onCondition, array $param = []): QueryTrait;
/**
* @param $tableName
* @param $alias
* @param $onCondition
* @param null $param
* @return $this
* @throws
* @param string $tableName
* @param string $alias
* @param string|array $onCondition
* @param array $param
* @return QueryTrait
*/
public function rightJoin($tableName, $alias, $onCondition, $param = NULL): static;
public function rightJoin(string $tableName, string $alias, string|array $onCondition, array $param = []): QueryTrait;
/**
* @param $tableName
* @param $alias
* @param $onCondition
* @param null $param
* @return $this
* @throws
* @param string $tableName
* @param string $alias
* @param string|array $onCondition
* @param array $param
* @return QueryTrait
*/
public function innerJoin($tableName, $alias, $onCondition, $param = NULL): static;
public function innerJoin(string $tableName, string $alias, string|array $onCondition, array $param = []): QueryTrait;
/**
* @param string $field
*
* @return $this
* @return QueryTrait
*/
public function sum(string $field): static;
public function sum(string $field): QueryTrait;
/**
* @param string $field
* @return $this
* @return QueryTrait
*/
public function max(string $field): static;
public function max(string $field): QueryTrait;
/**
* @param string $lngField
* @param string $latField
* @param int $lng1
* @param int $lat1
* @param int|float $lng1
* @param int|float $lat1
*
* @return $this
* @return QueryTrait
*/
public function distance(string $lngField, string $latField, int $lng1, int $lat1): static;
public function distance(string $lngField, string $latField, int|float $lng1, int|float $lat1): QueryTrait;
/**
* @param string|array $column
* @param string $sort
*
* @return $this
* @return QueryTrait [
*
* [
* 'addTime',
* 'descTime desc'
* ]
*/
public function orderBy(string|array $column, string $sort = 'DESC'): static;
public function orderBy(string|array $column, string $sort = 'DESC'): QueryTrait;
/**
* @param array|string $column
*
* @return $this
* @return QueryTrait
*/
public function select(array|string $column = '*'): static;
public function select(array|string $column = '*'): QueryTrait;
/**
* @return $this
* @return QueryTrait
*/
public function orderRand(): static;
public function orderRand(): QueryTrait;
/**
* @param array|Closure|string $conditionArray
* @param string $opera
* @param null $value
* @return $this
* @return QueryTrait
*/
public function whereOr(array|Closure|string $conditionArray = [], string $opera = '=', $value = null): static;
public function whereOr(array|Closure|string $conditionArray = [], string $opera = '=', $value = null): QueryTrait;
/**
* @param string $column
* @param string $value
* @return $this
* @return QueryTrait
*/
public function whereLike(string $column, string $value): static;
public function whereLike(string $column, string $value): QueryTrait;
/**
* @param string $column
* @param string $value
* @return $this
* @return QueryTrait
*/
public function whereLeftLike(string $column, string $value): static;
public function whereLeftLike(string $column, string $value): QueryTrait;
/**
* @param string $column
* @param string $value
* @return $this
* @return QueryTrait
*/
public function whereRightLike(string $column, string $value): static;
public function whereRightLike(string $column, string $value): QueryTrait;
/**
* @param string $column
* @param string $value
* @return $this
* @return QueryTrait
*/
public function whereNotLike(string $column, string $value): static;
public function whereNotLike(string $column, string $value): QueryTrait;
/**
* @param string $columns
* @param array|Closure $value
* @return $this
* @throws
* @return QueryTrait
*/
public function whereIn(string $columns, array|Closure $value): static;
public function whereIn(string $columns, array|Closure $value): QueryTrait;
/**
* @param string $columns
* @param array $value
* @return $this
* @return QueryTrait
*/
public function whereNotIn(string $columns, array $value): static;
public function whereNotIn(string $columns, array $value): QueryTrait;
/**
* @param string $column
* @param int $start
* @param int $end
* @return $this
* @param int|float $start
* @param int|float $end
* @return QueryTrait
*/
public function whereBetween(string $column, int $start, int $end): static;
public function whereBetween(string $column, int|float $start, int|float $end): QueryTrait;
/**
* @param string $column
* @param int $start
* @param int $end
* @return $this
* @param int|float $start
* @param int|float $end
* @return QueryTrait
*/
public function whereNotBetween(string $column, int $start, int $end): static;
public function whereNotBetween(string $column, int|float $start, int|float $end): QueryTrait;
/**
* @param array $column
* @return $this
* @return QueryTrait
*/
public function where(array $column): static;
public function where(array $column): QueryTrait;
/**
* @param string $column
* @param string $opera
* @param mixed $value
* @return $this
* @return QueryTrait
*/
public function whereMath(string $column, string $opera, mixed $value): static;
public function whereMath(string $column, string $opera, mixed $value): QueryTrait;
/**
* @param Closure $closure
* @return $this
* @return QueryTrait
*/
public function whereClosure(Closure $closure): static;
public function whereClosure(Closure $closure): QueryTrait;
/**
* @param string $name
* @param string|null $having
*
* @return $this
* @return QueryTrait
*/
public function groupBy(string $name, string $having = NULL): static;
public function groupBy(string $name, string $having = NULL): QueryTrait;
/**
* @param int $limit
*
* @return $this
* @return QueryTrait
*/
public function limit(int $limit = 20): static;
public function limit(int $limit = 20): QueryTrait;
/**
* @param int $offset
* @return $this
* @return QueryTrait
*/
public function offset(int $offset): static;
public function offset(int $offset): QueryTrait;
}