From 0fd9a9db3f742bf74989ce413244baa6dc2d9257 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 16 Jun 2016 11:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=87=AA=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E5=AD=97=E6=AE=B5=E7=9A=84=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E6=9C=BA=E5=88=B6=20=E5=8F=96=E6=B6=88Model?= =?UTF-8?q?=E7=B1=BB=E7=9A=84autoFetchFieldType=E5=92=8CfieldType=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=20=E6=94=B9=E4=B8=BA=E7=94=B1autoWriteTimestamp?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9B=B4=E6=8E=A5=E8=AE=BE=E7=BD=AE=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E7=B1=BB=E5=9E=8B=20=E6=94=AF=E6=8C=81=20dat?= =?UTF-8?q?etime=20date=20=E5=92=8C=20timestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 8cbc745c..92b49037 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -65,9 +65,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess protected $insert = []; // 更新自动完成列表 protected $update = []; - // 是否自动获取字段类型信息 - protected $autoFetchFieldType = false; - // 是否需要自动写入时间戳 + // 是否需要自动写入时间戳 如果设置为字符串 则表示时间字段的类型 protected $autoWriteTimestamp; // 创建时间字段 protected $createTime = 'create_time'; @@ -85,8 +83,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess protected $updateWhere; // 当前执行的关联对象 protected $relation; - // 属性类型 - protected $fieldType = []; // 验证失败是否抛出异常 protected $failException = false; @@ -118,11 +114,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $this->name = basename(str_replace('\\', '/', $this->class)); } - if ($this->autoFetchFieldType && empty($this->fieldType)) { - // 获取字段类型信息 - $this->fieldType = $this->db()->getTableInfo('', 'type'); - } - if (is_null($this->autoWriteTimestamp)) { // 自动写入时间戳 $this->autoWriteTimestamp = $this->db()->getConfig('auto_timestamp'); @@ -257,7 +248,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $value = $_SERVER['REQUEST_TIME']; break; } - } elseif (isset($this->fieldType[$name]) && preg_match('/(datetime|date|timestamp)/is', $this->fieldType[$name])) { + } elseif (is_string($this->autoWriteTimestamp) && in_array(strtolower($this->autoWriteTimestamp),['datetime','date','timestamp'])) { $value = date($this->dateFormat, $_SERVER['REQUEST_TIME']); } else { $value = $_SERVER['REQUEST_TIME'];