Merge remote-tracking branch 'origin/master'

This commit is contained in:
2021-04-29 10:35:17 +08:00
2 changed files with 1013 additions and 1013 deletions
+5 -5
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,16 +794,16 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
if (!$this->has($name)) { if (method_exists($this, 'set' . ucfirst($name))) {
parent::__set($name, $value); $this->{'set' . ucfirst($name)}($value);
return; } 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;
} }
}
/** /**
+1 -1
View File
@@ -112,7 +112,7 @@ class Columns extends Component
*/ */
public function decode($val, $format = null): mixed public function decode($val, $format = null): mixed
{ {
if (empty($format)) { if (empty($format) || $val === null) {
return $val; return $val;
} }
$format = strtolower($format); $format = strtolower($format);