From 679f2e9310fd1a58e6ab3969ec59c685e8fbbf1f Mon Sep 17 00:00:00 2001 From: molong Date: Sat, 23 Sep 2017 20:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=9E=8B=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/model/BaseModel.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/common/model/BaseModel.php b/application/common/model/BaseModel.php index 996d942a..6c8174ef 100644 --- a/application/common/model/BaseModel.php +++ b/application/common/model/BaseModel.php @@ -31,6 +31,7 @@ class BaseModel { protected $dateFormat; // 字段类型或者格式转换 protected $type = []; + protected $attrDb = 'Attribute'; public function __construct($name) { $this->db = db($name); @@ -39,7 +40,7 @@ class BaseModel { public function save($data, $where = array()) { $this->data = $data; $rule = $msg = array(); - $attr = db('Attribute')->where('model_id', $data['model_id'])->select(); + $attr = db($this->attrDb)->where('model_id', $data['model_id'])->select(); foreach ($attr as $key => $value) { if ($value['is_must'] == 1) { $rule[$value['name']] = "require"; @@ -116,7 +117,7 @@ class BaseModel { * @return $this */ public function setAttr($name, $value, $data = []) { - if ((is_null($value) || !$value) && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) { + if ((is_null($value) || !$value || $value != '0') && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) { // 自动写入的时间戳字段 $value = $this->autoWriteTimestamp($name); } else {