This commit is contained in:
as2252258@163.com
2021-07-26 04:59:03 +08:00
parent abdaeb3e08
commit 826b3b2102
7 changed files with 394 additions and 342 deletions
+2 -20
View File
@@ -126,7 +126,7 @@ class ActiveRecord extends BaseActiveRecord
if (empty($attributes)) {
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
}
$select = self::getModelClass();
$select = duplicate(static::class);
$select->attributes = $attributes;
if (!$select->save()) {
return $logger->addError($select->getLastError(), 'mysql');
@@ -150,7 +150,7 @@ class ActiveRecord extends BaseActiveRecord
/** @var static $select */
$select = static::find()->where($condition)->first();
if (empty($select)) {
$select = self::getModelClass();
$select = duplicate(static::class);
}
$select->attributes = $attributes;
if (!$select->save()) {
@@ -160,20 +160,6 @@ class ActiveRecord extends BaseActiveRecord
}
/**
* @return static
* @throws Exception
*/
private static function getModelClass(): static
{
/** @var Channel $channel */
$channel = Snowflake::app()->get('channel');
return $channel->pop(static::class, function () {
return new static();
});
}
/**
* @param $action
* @param $columns
@@ -306,10 +292,6 @@ class ActiveRecord extends BaseActiveRecord
$data[$key] = $this->{$item}($data[$key] ?? null);
}
$data = array_merge($data, $this->runRelate());
$class = Snowflake::app()->getChannel();
$class->push($this, static::class);
return $data;
}