This commit is contained in:
2021-07-29 13:51:54 +08:00
parent 2bd3dd6bb6
commit 677f771b3b
2 changed files with 18 additions and 17 deletions
+5 -5
View File
@@ -53,7 +53,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @param array $config
* @throws
*/
public function __construct($model, $config = [])
public function __construct($model, array $config = [])
{
$this->modelClass = $model;
@@ -117,7 +117,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @param bool $isArray
* @return $this
*/
public function asArray($isArray = TRUE): static
public function asArray(bool $isArray = TRUE): static
{
$this->asArray = $isArray;
return $this;
@@ -130,7 +130,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @return mixed
* @throws Exception
*/
public function execute($sql, $params = []): Command
public function execute($sql, array $params = []): Command
{
return $this->modelClass::getDb()->createCommand($sql, $this->modelClass::getDbName(), $params);
}
@@ -204,7 +204,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @return array|null
* @throws Exception
*/
public function column(string $field, $setKey = ''): ?array
public function column(string $field, string $setKey = ''): ?array
{
return $this->all()->column($field, $setKey);
}
@@ -316,7 +316,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @return string|bool
* @throws Exception
*/
public function delete($getSql = false): string|bool
public function delete(bool $getSql = false): string|bool
{
$sql = $this->builder->delete();
if ($getSql === false) {
+13 -12
View File
@@ -80,11 +80,12 @@ trait QueryTrait
/**
* @param $condition
* @param $condition1
* @param $condition2
* @param string|array $condition
* @param string|array|Closure $condition1
* @param string|array|Closure $condition2
* @return $this
* @throws Exception
* @throws NotFindClassException
* @throws ReflectionException
*/
public function if(string|array $condition, string|array|Closure $condition1, string|array|Closure $condition2): static
{
@@ -224,7 +225,7 @@ trait QueryTrait
*
* select * from tableName as t1
*/
public function alias($alias = 't1'): static
public function alias(string $alias = 't1'): static
{
$this->alias = $alias;
return $this;
@@ -294,8 +295,8 @@ trait QueryTrait
}
/**
* @param $tableName
* @param $alias
* @param string $tableName
* @param string $alias
* @param $onCondition
* @param null $param
* @return $this
@@ -419,7 +420,7 @@ trait QueryTrait
* 'descTime desc'
* ]
*/
public function orderBy($column, $sort = 'DESC'): static
public function orderBy($column, string $sort = 'DESC'): static
{
if (empty($column)) {
return $this;
@@ -442,7 +443,7 @@ trait QueryTrait
* @return $this
*
*/
private function addOrder($column, $sort = 'DESC'): static
private function addOrder($column, string $sort = 'DESC'): static
{
$column = trim($column);
@@ -459,7 +460,7 @@ trait QueryTrait
*
* @return $this
*/
public function select($column = '*'): static
public function select(array|string $column = '*'): static
{
if ($column == '*') {
$this->select = $column;
@@ -501,7 +502,7 @@ trait QueryTrait
* @param string $opera
* @return QueryTrait
*/
public function and(string $columns, string|int|null|bool $value = NULL, $opera = '='): static
public function and(string $columns, string|int|null|bool $value = NULL, string $opera = '='): static
{
if (!is_numeric($value) && !is_bool($value)) {
$value = '\'' . $value . '\'';
@@ -817,7 +818,7 @@ trait QueryTrait
* @throws ReflectionException
* @throws Exception
*/
public function makeClosureFunction(Closure|array $closure, $onlyWhere = false): string
public function makeClosureFunction(Closure|array $closure, bool $onlyWhere = false): string
{
$generate = $this->makeNewSqlGenerate();
if ($closure instanceof Closure) {