From 51a5fcf4230c6ec3b8dc6f7140fc51c260482b0d Mon Sep 17 00:00:00 2001 From: kingsley <165256676@qq.com> Date: Mon, 4 Mar 2013 15:56:40 +0800 Subject: [PATCH] Update Db.class.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 开发的工程中发现少有这样的功能,不知道我这方法有那些弊端,但是却是解决了需求。 --- ThinkPHP/Lib/Core/Db.class.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ThinkPHP/Lib/Core/Db.class.php b/ThinkPHP/Lib/Core/Db.class.php index 07fbbfa..9872e04 100644 --- a/ThinkPHP/Lib/Core/Db.class.php +++ b/ThinkPHP/Lib/Core/Db.class.php @@ -335,8 +335,16 @@ protected function parseLock($lock=false) { protected function parseSet($data) { foreach ($data as $key=>$val){ $value = $this->parseValue($val); - if(is_scalar($value)) // 过滤非标量数据 - $set[] = $this->parseKey($key).'='.$value; + + if($val['field']!=""){ + //增加updatte set 字段1=字段2需求 + //data['xx']=array("field"=>'yy'); + $tt=$val['field']; + $set[] = $this->parseKey($key).'='.$tt; + }else{ + if(is_scalar($value)) // 过滤非标量数据 + $set[] = $this->parseKey($key).'='.$value; + } } return ' SET '.implode(',',$set); } @@ -1029,4 +1037,4 @@ public function __destruct() { // 关闭数据库 由驱动类定义 public function close(){} -} \ No newline at end of file +}