From 6d0c3a633e4918d106ca4981130611786ecceddf Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 12 Jun 2016 18:26:40 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E7=9A=84=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E5=AE=9A=E4=B9=89=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=95=B0=E7=BB=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 1b7b251f..c1ab43c8 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -286,12 +286,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * 数据写入 类型转换 * @access public * @param mixed $value 值 - * @param string $type 要转换的类型 + * @param string|array $type 要转换的类型 * @return mixed */ protected function writeTransform($value, $type) { - if (strpos($type, ':')) { + if(is_array($type)){ + $param = $type[1]; + $type = $type[0]; + }elseif (strpos($type, ':')) { list($type, $param) = explode(':', $type, 2); } switch ($type) { @@ -365,12 +368,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * 数据读取 类型转换 * @access public * @param mixed $value 值 - * @param string $type 要转换的类型 + * @param string|array $type 要转换的类型 * @return mixed */ protected function readTransform($value, $type) { - if (strpos($type, ':')) { + if(is_array($type)){ + $param = $type[1]; + $type = $type[0]; + }elseif (strpos($type, ':')) { list($type, $param) = explode(':', $type, 2); } switch ($type) {