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 * @param array $config
* @throws * @throws
*/ */
public function __construct($model, $config = []) public function __construct($model, array $config = [])
{ {
$this->modelClass = $model; $this->modelClass = $model;
@@ -117,7 +117,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @param bool $isArray * @param bool $isArray
* @return $this * @return $this
*/ */
public function asArray($isArray = TRUE): static public function asArray(bool $isArray = TRUE): static
{ {
$this->asArray = $isArray; $this->asArray = $isArray;
return $this; return $this;
@@ -130,7 +130,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @return mixed * @return mixed
* @throws Exception * @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); return $this->modelClass::getDb()->createCommand($sql, $this->modelClass::getDbName(), $params);
} }
@@ -204,7 +204,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @return array|null * @return array|null
* @throws Exception * @throws Exception
*/ */
public function column(string $field, $setKey = ''): ?array public function column(string $field, string $setKey = ''): ?array
{ {
return $this->all()->column($field, $setKey); return $this->all()->column($field, $setKey);
} }
@@ -316,7 +316,7 @@ class ActiveQuery extends Component implements ISqlBuilder
* @return string|bool * @return string|bool
* @throws Exception * @throws Exception
*/ */
public function delete($getSql = false): string|bool public function delete(bool $getSql = false): string|bool
{ {
$sql = $this->builder->delete(); $sql = $this->builder->delete();
if ($getSql === false) { if ($getSql === false) {
+13 -12
View File
@@ -80,11 +80,12 @@ trait QueryTrait
/** /**
* @param $condition * @param string|array $condition
* @param $condition1 * @param string|array|Closure $condition1
* @param $condition2 * @param string|array|Closure $condition2
* @return $this * @return $this
* @throws Exception * @throws NotFindClassException
* @throws ReflectionException
*/ */
public function if(string|array $condition, string|array|Closure $condition1, string|array|Closure $condition2): static 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 * select * from tableName as t1
*/ */
public function alias($alias = 't1'): static public function alias(string $alias = 't1'): static
{ {
$this->alias = $alias; $this->alias = $alias;
return $this; return $this;
@@ -294,8 +295,8 @@ trait QueryTrait
} }
/** /**
* @param $tableName * @param string $tableName
* @param $alias * @param string $alias
* @param $onCondition * @param $onCondition
* @param null $param * @param null $param
* @return $this * @return $this
@@ -419,7 +420,7 @@ trait QueryTrait
* 'descTime desc' * 'descTime desc'
* ] * ]
*/ */
public function orderBy($column, $sort = 'DESC'): static public function orderBy($column, string $sort = 'DESC'): static
{ {
if (empty($column)) { if (empty($column)) {
return $this; return $this;
@@ -442,7 +443,7 @@ trait QueryTrait
* @return $this * @return $this
* *
*/ */
private function addOrder($column, $sort = 'DESC'): static private function addOrder($column, string $sort = 'DESC'): static
{ {
$column = trim($column); $column = trim($column);
@@ -459,7 +460,7 @@ trait QueryTrait
* *
* @return $this * @return $this
*/ */
public function select($column = '*'): static public function select(array|string $column = '*'): static
{ {
if ($column == '*') { if ($column == '*') {
$this->select = $column; $this->select = $column;
@@ -501,7 +502,7 @@ trait QueryTrait
* @param string $opera * @param string $opera
* @return QueryTrait * @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)) { if (!is_numeric($value) && !is_bool($value)) {
$value = '\'' . $value . '\''; $value = '\'' . $value . '\'';
@@ -817,7 +818,7 @@ trait QueryTrait
* @throws ReflectionException * @throws ReflectionException
* @throws Exception * @throws Exception
*/ */
public function makeClosureFunction(Closure|array $closure, $onlyWhere = false): string public function makeClosureFunction(Closure|array $closure, bool $onlyWhere = false): string
{ {
$generate = $this->makeNewSqlGenerate(); $generate = $this->makeNewSqlGenerate();
if ($closure instanceof Closure) { if ($closure instanceof Closure) {