改名
This commit is contained in:
@@ -401,16 +401,8 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
if (($lastId = $commandExec->save(true, $this->hasAutoIncrement())) === false) {
|
if (($lastId = $commandExec->save(true, $this->hasAutoIncrement())) === false) {
|
||||||
throw new Exception('保存失败.' . $sqlBuilder);
|
throw new Exception('保存失败.' . $sqlBuilder);
|
||||||
}
|
}
|
||||||
if ($this->hasAutoIncrement()) {
|
|
||||||
$this->setAttribute($this->getAutoIncrement(), (int)$lastId);
|
|
||||||
} else if ($this->hasPrimary()) {
|
|
||||||
$primary = $this->getPrimary();
|
|
||||||
if (!isset($param[$primary]) || empty($param[$primary])) {
|
|
||||||
$this->setAttribute($primary, (int)$lastId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$trance->commit();
|
$trance->commit();
|
||||||
$this->setAttributes($param);
|
$this->setPrimary($lastId, $param);
|
||||||
$this->afterSave($attributes, $param);
|
$this->afterSave($attributes, $param);
|
||||||
$lastId = $this->refresh();
|
$lastId = $this->refresh();
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
@@ -421,6 +413,27 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $lastId
|
||||||
|
* @param $param
|
||||||
|
* @return mixed
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private function setPrimary($lastId, $param)
|
||||||
|
{
|
||||||
|
if ($this->hasAutoIncrement()) {
|
||||||
|
return $this->setAttribute($this->getAutoIncrement(), (int)$lastId);
|
||||||
|
}
|
||||||
|
if ($this->hasPrimary()) {
|
||||||
|
$primary = $this->getPrimary();
|
||||||
|
if (!isset($param[$primary]) || empty($param[$primary])) {
|
||||||
|
$this->setAttribute($primary, (int)$lastId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->setAttributes($param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $param
|
* @param $param
|
||||||
* @param $condition
|
* @param $condition
|
||||||
|
|||||||
Reference in New Issue
Block a user