This commit is contained in:
2026-07-17 17:52:19 +08:00
parent 594e6b2ea7
commit 31f75e053e
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -253,7 +253,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
return NULL; return NULL;
} }
$query = new ActiveQuery($model = static::instance()); $query = new ActiveQuery($model = static::instance());
$query->from($model->getTable())->alias('t1'); $query->from($model->getTable());
if (is_numeric($param)) { if (is_numeric($param)) {
$query->where([$model->getPrimary() => +$param]); $query->where([$model->getPrimary() => +$param]);
} else if (is_array($param)) { } else if (is_array($param)) {
@@ -279,7 +279,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
{ {
$model = static::instance(); $model = static::instance();
$query = new ActiveQuery($model); $query = new ActiveQuery($model);
$query->from($model->getTable())->alias('t1')->where([$model->getPrimary() => $param]); $query->from($model->getTable())->where([$model->getPrimary() => $param]);
return $query->first(); return $query->first();
} }
@@ -324,7 +324,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
public static function all(string|array $condition): Collection public static function all(string|array $condition): Collection
{ {
$model = new ActiveQuery(static::instance()); $model = new ActiveQuery(static::instance());
$model->from($model->getTable())->alias('t1'); $model->from($model->getTable());
if (is_array($condition)) { if (is_array($condition)) {
$model->where($condition); $model->where($condition);
} else { } else {
@@ -341,7 +341,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
public static function query(): ActiveQuery public static function query(): ActiveQuery
{ {
$model = new ActiveQuery(static::instance()); $model = new ActiveQuery(static::instance());
$model->select()->from($model->getTable())->alias('t1'); $model->select()->from($model->getTable());
return $model; return $model;
} }
+1 -1
View File
@@ -32,7 +32,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq
return $this->where; return $this->where;
} }
} }
public array $select = ['t1.*'] { public array $select = ['*'] {
&get { &get {
return $this->select; return $this->select;
} }