From b54ee372f58e2f1e005c680c0f400d0085e1bb30 Mon Sep 17 00:00:00 2001 From: ThinkPHP Date: Fri, 26 Apr 2013 21:40:26 +0800 Subject: [PATCH] =?UTF-8?q?Think/Db/Driver=E7=B1=BB=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8F=82=E6=95=B0=E7=BB=91=E5=AE=9A=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Think/Db/Driver.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Library/Think/Db/Driver.php b/Library/Think/Db/Driver.php index c5d021fa..adb325bb 100644 --- a/Library/Think/Db/Driver.php +++ b/Library/Think/Db/Driver.php @@ -327,9 +327,13 @@ abstract class Driver { foreach ($data as $key=>$val){ $value = $this->parseValue($val); if(is_scalar($value)) {// 过滤非标量数据 - $name = md5($key); - $set[] = $this->parseKey($key).'=:T'.$name; - $this->bindParam($name,$value); + if(0===strpos($value,':')){ + $set[] = $this->parseKey($key).'='.$value; + }else{ + $name = md5($key); + $set[] = $this->parseKey($key).'=:T'.$name; + $this->bindParam($name,$value); + } } } return ' SET '.implode(',',$set); @@ -740,9 +744,13 @@ abstract class Driver { $value = $this->parseValue($val); if(is_scalar($value)) { // 过滤非标量数据 $fields[] = $this->parseKey($key); - $name = md5($key); - $values[] = ':'.$name; - $this->bindParam($name,$value); + if(0===strpos($value,':')){ + $values[] = $value; + }else{ + $name = md5($key); + $values[] = ':T'.$name; + $this->bindParam($name,$value); + } } } $sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';