改名
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) {
|
||||
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();
|
||||
$this->setAttributes($param);
|
||||
$this->setPrimary($lastId, $param);
|
||||
$this->afterSave($attributes, $param);
|
||||
$lastId = $this->refresh();
|
||||
} 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 $condition
|
||||
|
||||
Reference in New Issue
Block a user