This commit is contained in:
2021-09-28 18:54:07 +08:00
parent 27e87a461e
commit 079cd12399
18 changed files with 659 additions and 678 deletions
+9 -9
View File
@@ -118,15 +118,15 @@ class ActiveQuery extends Component implements ISqlBuilder
*/
public function execute($sql, array $params = []): Command
{
return $this->modelClass::getDb()->createCommand($sql, $params);
return $this->modelClass->getConnection()->createCommand($sql, $params);
}
/**
* @return ActiveRecord|null
* @return ModelInterface|null
* @throws Exception
*/
public function first(): ActiveRecord|null
public function first(): ModelInterface|null
{
$data = $this->execute($this->builder->one())->one();
if (empty($data)) {
@@ -207,22 +207,22 @@ class ActiveQuery extends Component implements ISqlBuilder
}
/**
* @param ActiveRecord $model
* @param ModelInterface $model
* @param $data
* @return ActiveRecord
* @return ModelInterface
* @throws Exception
*/
public function populate(ActiveRecord $model, $data): ActiveRecord
public function populate(ModelInterface $model, $data): ModelInterface
{
return $this->getWith($model::populate($data));
}
/**
* @param ActiveRecord $model
* @return ActiveRecord
* @param ModelInterface $model
* @return ModelInterface
*/
public function getWith(ActiveRecord $model): ActiveRecord
public function getWith(ModelInterface $model): ModelInterface
{
if (empty($this->with) || !is_array($this->with)) {
return $model;