From 6011b5756136af6ca564a87cd1e56820427a190c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 9 Feb 2016 20:27:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88Model=E7=B1=BB=E7=9A=84create?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84=E7=AC=AC=E4=BA=8C=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 5 ++--- library/traits/model/Auto.php | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 2bc38d6c..d6affd93 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -900,11 +900,10 @@ class Model * 创建数据对象 但不保存到数据库 * @access public * @param mixed $data 创建数据 - * @param string $type 状态 * @return mixed * @throws \think\Exception */ - public function create($data = '', $type = '') + public function create($data = '') { // 如果没有传值默认取POST数据 if (empty($data)) { @@ -1007,7 +1006,7 @@ class Model } } // 过滤创建的数据 - $this->_create_filter($data, $type); + $this->_create_filter($data); // 赋值当前数据对象 $this->data = $data; // 返回创建的数据以供其他调用 diff --git a/library/traits/model/Auto.php b/library/traits/model/Auto.php index 753aaaf0..dc2b3205 100644 --- a/library/traits/model/Auto.php +++ b/library/traits/model/Auto.php @@ -70,12 +70,12 @@ trait Auto } // 数据自动验证 - if (!$this->autoValidation($data, $type)) { + if (!$this->_autoValidation($data, $type)) { return false; } // 验证完成生成数据对象 - if ($this->autoCheckFields && empty($this->options['link'])) { + if (empty($this->options['link'])) { // 开启字段检测并且没有关联表 则过滤非法字段数据 $fields = $this->getFields(); foreach ($keys as $i => $key) { @@ -86,7 +86,7 @@ trait Auto } // 创建完成对数据进行自动处理 - $this->autoOperation($data, $type); + $this->_autoOperation($data, $type); // 验证后的回调方法 $this->_after_create($data, $this->options); // 赋值当前数据对象 @@ -134,7 +134,7 @@ trait Auto * @param string $type 创建类型 * @return mixed */ - private function autoOperation(&$data, $type) + protected function _autoOperation(&$data, $type) { if (isset($this->options['auto'])) { if (false === $this->options['auto']) { @@ -239,7 +239,7 @@ trait Auto * @param string $type 创建类型 * @return boolean */ - protected function autoValidation(&$data, $type) + protected function _autoValidation(&$data, $type) { if (isset($this->options['validate'])) { if (false === $this->options['validate']) {