eee
This commit is contained in:
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Base;
|
||||
|
||||
use Closure;
|
||||
|
||||
interface ActiveQueryInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param callable $callable
|
||||
* @return $this
|
||||
*/
|
||||
public function when(string $column, callable $callable): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $whereRaw
|
||||
* @return $this
|
||||
*/
|
||||
public function whereRaw(string $whereRaw): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereLocate(string $column, string $value): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNull(string $column): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @return $this
|
||||
*/
|
||||
public function whereEmpty(string $column): static;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNotEmpty(string $column): static;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNotNull(string $column): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $alias
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* select * from tableName as t1
|
||||
*/
|
||||
public function alias(string $alias = 't1'): static;
|
||||
|
||||
/**
|
||||
* @param string|Closure $tableName
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function from(string|Closure $tableName): static;
|
||||
|
||||
/**
|
||||
* @param string $tableName
|
||||
* @param string $alias
|
||||
* @param $onCondition
|
||||
* @param null $param
|
||||
* @return $this
|
||||
* @throws
|
||||
*/
|
||||
public function leftJoin(string $tableName, string $alias, $onCondition, $param = NULL): static;
|
||||
|
||||
/**
|
||||
* @param $tableName
|
||||
* @param $alias
|
||||
* @param $onCondition
|
||||
* @param null $param
|
||||
* @return $this
|
||||
* @throws
|
||||
*/
|
||||
public function rightJoin($tableName, $alias, $onCondition, $param = NULL): static;
|
||||
|
||||
/**
|
||||
* @param $tableName
|
||||
* @param $alias
|
||||
* @param $onCondition
|
||||
* @param null $param
|
||||
* @return $this
|
||||
* @throws
|
||||
*/
|
||||
public function innerJoin($tableName, $alias, $onCondition, $param = NULL): static;
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function sum(string $field): static;
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @return $this
|
||||
*/
|
||||
public function max(string $field): static;
|
||||
|
||||
/**
|
||||
* @param string $lngField
|
||||
* @param string $latField
|
||||
* @param int $lng1
|
||||
* @param int $lat1
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function distance(string $lngField, string $latField, int $lng1, int $lat1): static;
|
||||
|
||||
/**
|
||||
* @param string|array $column
|
||||
* @param string $sort
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* [
|
||||
* 'addTime',
|
||||
* 'descTime desc'
|
||||
* ]
|
||||
*/
|
||||
public function orderBy(string|array $column, string $sort = 'DESC'): static;
|
||||
|
||||
/**
|
||||
* @param array|string $column
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function select(array|string $column = '*'): static;
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function orderRand(): static;
|
||||
|
||||
/**
|
||||
* @param array|Closure|string $conditionArray
|
||||
* @param string $opera
|
||||
* @param null $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereOr(array|Closure|string $conditionArray = [], string $opera = '=', $value = null): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereLike(string $column, string $value): static;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereLeftLike(string $column, string $value): static;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereRightLike(string $column, string $value): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNotLike(string $column, string $value): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $columns
|
||||
* @param array|Closure $value
|
||||
* @return $this
|
||||
* @throws
|
||||
*/
|
||||
public function whereIn(string $columns, array|Closure $value): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $columns
|
||||
* @param array $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNotIn(string $columns, array $value): static;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param int $start
|
||||
* @param int $end
|
||||
* @return $this
|
||||
*/
|
||||
public function whereBetween(string $column, int $start, int $end): static;
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param int $start
|
||||
* @param int $end
|
||||
* @return $this
|
||||
*/
|
||||
public function whereNotBetween(string $column, int $start, int $end): static;
|
||||
|
||||
/**
|
||||
* @param array $column
|
||||
* @return $this
|
||||
*/
|
||||
public function where(array $column): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $opera
|
||||
* @param mixed $value
|
||||
* @return $this
|
||||
*/
|
||||
public function whereMath(string $column, string $opera, mixed $value): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param Closure $closure
|
||||
* @return $this
|
||||
*/
|
||||
public function whereClosure(Closure $closure): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string|null $having
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function groupBy(string $name, string $having = NULL): static;
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function limit(int $limit = 20): static;
|
||||
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
* @return $this
|
||||
*/
|
||||
public function offset(int $offset): static;
|
||||
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
namespace Database;
|
||||
|
||||
|
||||
use Database\Base\ActiveQueryInterface;
|
||||
use Exception;
|
||||
|
||||
defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
||||
@@ -21,6 +22,8 @@ defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a
|
||||
*
|
||||
* @property $attributes
|
||||
* @property-read $oldAttributes
|
||||
*
|
||||
* @mixin ActiveQueryInterface
|
||||
*/
|
||||
class Model extends Base\Model
|
||||
{
|
||||
@@ -130,6 +133,22 @@ class Model extends Base\Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public static function __callStatic(string $name, array $arguments)
|
||||
{
|
||||
// TODO: Change the autogenerated stub
|
||||
if (method_exists(static::class, $name)) {
|
||||
return call_user_func(static::class . '::' . $name, ...$arguments);
|
||||
} else {
|
||||
return static::query()->{$name}(...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $columns
|
||||
* @param $action
|
||||
|
||||
Reference in New Issue
Block a user