Skip to content

Commit

Permalink
fix(QueryBuilder): PHP 8.1 table 设置为字符串,以避免 Passing null to paramet…
Browse files Browse the repository at this point in the history
…er of type string is deprecated 错误
  • Loading branch information
twinh committed Nov 30, 2023
1 parent db903ba commit 0eb223f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/Db/QueryBuilderPropsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ trait QueryBuilderPropsTrait
/**
* The name of the table
*
* @var string|null
* @var string
*/
protected $table;
protected $table = '';

/**
* The column names of the table
Expand Down Expand Up @@ -55,7 +55,7 @@ trait QueryBuilderPropsTrait
protected $queryParts = [
'select' => [],
'distinct' => null,
'from' => null,
'from' => '',
'join' => [],
'set' => [],
'where' => [],
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/QueryBuilderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public function getDbKeyConverter(): callable
*/
protected function getTable(): ?string
{
return $this->table ?? null;
return $this->table;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/ModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ protected function toRet($merge = []): Ret
*/
protected function getTable(): string
{
if (!isset($this->table)) {
if (!$this->table) {
$str = $this->wei->str;
$this->table = $str->pluralize($str->snake($this->getModelBaseName()));
}
Expand Down

0 comments on commit 0eb223f

Please sign in to comment.