Skip to content

Commit

Permalink
Fix 查询值为null时,写入模型失败的BUG (swoft-cloud/swoft-component#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo authored and huangzhhui committed Jul 12, 2018
1 parent a69843a commit d9218a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Helper/EntityHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ public static function arrayToEntity(array $data, string $className)

if (\method_exists($object, $setterMethod)) {
$attrs[$field] = $value;

$object->$setterMethod($value);
// 当从数据库取出来的数据不为null时,再进行模型赋值
if ($value !== null) {
$object->$setterMethod($value);
}
}
}
if (\method_exists($object, 'setAttrs')) {
Expand Down

0 comments on commit d9218a3

Please sign in to comment.