From f0aaa7290c2c64c33c1e63cf45b6ff1ef7c0b2ab Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 27 Mar 2017 17:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84readTr?= =?UTF-8?q?ansform=E5=92=8CwriteTransform=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/think/Model.php b/library/think/Model.php index ae4f2993..47fdc502 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -367,6 +367,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ protected function writeTransform($value, $type) { + if (is_null($value)) { + return null; + } + if (is_array($type)) { list($type, $param) = $type; } elseif (strpos($type, ':')) { @@ -475,6 +479,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ protected function readTransform($value, $type) { + if (is_null($value)) { + return null; + } + if (is_array($type)) { list($type, $param) = $type; } elseif (strpos($type, ':')) {