From 71bcc1bb7be4c2a354cf84f55dd4e2bba758b547 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 7 Jun 2016 10:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Merge=E7=B1=BB=20=E6=94=B9?= =?UTF-8?q?=E8=BF=9BFile=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/File.php | 1 + library/think/model/Merge.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/File.php b/library/think/File.php index fc888b10..9ce8f36e 100644 --- a/library/think/File.php +++ b/library/think/File.php @@ -106,6 +106,7 @@ class File extends SplFileObject return false; } + $path = rtrim($path, DS) . DS; // 文件保存命名规则 $savename = $this->getSaveName($savename); diff --git a/library/think/model/Merge.php b/library/think/model/Merge.php index b26c8494..c4903c59 100644 --- a/library/think/model/Merge.php +++ b/library/think/model/Merge.php @@ -145,13 +145,14 @@ class Merge extends Model * @param mixed $data 数据 * @param array $where 更新条件 * @param bool $getId 新增的时候是否获取id + * @param bool $replace 是否replace * @return mixed */ - public function save($data = [], $where = [], $getId = true) + public function save($data = [], $where = [], $getId = true, $replace = false) { if (!empty($data)) { // 数据自动验证 - if (!$this->validateData()) { + if (!$this->validateData($data)) { return false; } // 数据对象赋值 @@ -214,7 +215,7 @@ class Merge extends Model // 处理模型数据 $data = $this->parseData($this->name, $this->data); // 写入主表数据 - $result = $db->name($this->name)->strict(false)->insert($data); + $result = $db->name($this->name)->strict(false)->insert($data, $replace); if ($result) { $insertId = $db->getLastInsID(); // 写入外键数据