This commit is contained in:
as2252258@163.com
2021-04-29 01:08:59 +08:00
parent 62408b5041
commit 7ea6f7b6a0
+5 -1
View File
@@ -434,7 +434,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
$trance = $dbConnection->beginTransaction(); $trance = $dbConnection->beginTransaction();
try { try {
if (!($lastId = (int)$dbConnection->createCommand($sql, $param)->save(true, $this))) { if (!($lastId = (int)$dbConnection->createCommand($sql, $param)->save(true, $this))) {
throw new Exception('保存失败.' . $sql); throw new Exception('保存失败.');
} }
$trance->commit(); $trance->commit();
$lastId = $this->setPrimary($lastId, $param); $lastId = $this->setPrimary($lastId, $param);
@@ -794,12 +794,16 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
if (method_exists($this, 'set' . ucfirst($name))) {
$this->{'set' . ucfirst($name)}($value);
} else {
$method = $this->_get_annotation($name, self::SET); $method = $this->_get_annotation($name, self::SET);
if (!empty($method)) { if (!empty($method)) {
$value = $this->{$method}($value); $value = $this->{$method}($value);
} }
$this->_attributes[$name] = $value; $this->_attributes[$name] = $value;
} }
}
/** /**