diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index 0a2b6624..4c8485e8 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -177,28 +177,13 @@ class ActiveRecord extends BaseActiveRecord return $this->save($fields); } - /** - * @param array $params - * @param array $condition - * @return bool|static - * @throws Exception - */ - public static function insertOrUpdate(array $params, array $condition): bool|static - { - $first = static::findOrCreate($condition, $params); - $first->attributes = $params; - if (!$first->save()) { - return false; - } - return $first; - } /** * @param array $data * @return bool * @throws Exception */ - public static function batchInsert(array $data): bool + public static function inserts(array $data): bool { /** @var static $class */ $class = Snowflake::createObject(static::className()); @@ -242,7 +227,7 @@ class ActiveRecord extends BaseActiveRecord * @return bool * @throws Exception */ - public static function batchUpdate($condition, $attributes = []): bool + public static function updateAll(mixed $condition, $attributes = []): bool { $condition = static::find()->where($condition); return $condition->batchUpdate($attributes); diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 1dcb3068..201c2882 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -457,7 +457,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess * @return $this|bool * @throws Exception */ - private function update($fields, $condition, $param): bool|static + private function updateInternal($fields, $condition, $param): bool|static { if (empty($param)) { return true; @@ -509,7 +509,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess [$change, $condition, $fields] = $this->filtration_and_separation(); if (!$this->isNewExample) { - return $this->update($fields, $condition, $change); + return $this->updateInternal($fields, $condition, $change); } return $this->insert($change, $fields); }