改名
This commit is contained in:
@@ -177,28 +177,13 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
return $this->save($fields);
|
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
|
* @param array $data
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function batchInsert(array $data): bool
|
public static function inserts(array $data): bool
|
||||||
{
|
{
|
||||||
/** @var static $class */
|
/** @var static $class */
|
||||||
$class = Snowflake::createObject(static::className());
|
$class = Snowflake::createObject(static::className());
|
||||||
@@ -242,7 +227,7 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function batchUpdate($condition, $attributes = []): bool
|
public static function updateAll(mixed $condition, $attributes = []): bool
|
||||||
{
|
{
|
||||||
$condition = static::find()->where($condition);
|
$condition = static::find()->where($condition);
|
||||||
return $condition->batchUpdate($attributes);
|
return $condition->batchUpdate($attributes);
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
* @return $this|bool
|
* @return $this|bool
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function update($fields, $condition, $param): bool|static
|
private function updateInternal($fields, $condition, $param): bool|static
|
||||||
{
|
{
|
||||||
if (empty($param)) {
|
if (empty($param)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -509,7 +509,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
[$change, $condition, $fields] = $this->filtration_and_separation();
|
[$change, $condition, $fields] = $this->filtration_and_separation();
|
||||||
|
|
||||||
if (!$this->isNewExample) {
|
if (!$this->isNewExample) {
|
||||||
return $this->update($fields, $condition, $change);
|
return $this->updateInternal($fields, $condition, $change);
|
||||||
}
|
}
|
||||||
return $this->insert($change, $fields);
|
return $this->insert($change, $fields);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user