From eb75913c2cb133ff518e7024f68f2a215dcd8565 Mon Sep 17 00:00:00 2001 From: molong Date: Mon, 9 Jul 2018 12:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=B7=BB=E5=8A=A0=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/model/Base.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application/common/model/Base.php b/application/common/model/Base.php index b78cc1d1..8ac089de 100644 --- a/application/common/model/Base.php +++ b/application/common/model/Base.php @@ -4,5 +4,27 @@ namespace app\common\model; use think\Model; class Base extends Model { + protected $param; + protected $type = array( + 'id' => 'integer', + 'cover_id' => 'integer', + ); + public function initialize(){ + parent::initialize(); + $this->param = \think\Request::instance()->param(); + } + + /** + * 数据修改 + * @return [bool] [是否成功] + */ + public function change(){ + $data = \think\Request::instance()->post(); + if (isset($data['id']) && $data['id']) { + return $this->save($data, array('id'=>$data['id'])); + }else{ + return $this->save($data); + } + } } \ No newline at end of file