From e4dc3e47d4c42ee363d0b62f4bb7823bf90cac7d Mon Sep 17 00:00:00 2001 From: ThinkPHP Date: Sat, 27 Apr 2013 17:55:34 +0800 Subject: [PATCH] =?UTF-8?q?Think/Db/Driver=E7=B1=BB=20=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=96=B9=E6=B3=95bindParam=E6=94=B9=E4=B8=BA?= =?UTF-8?q?bindValue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免多个参数绑定时存在的引用问题 --- Library/Think/Db/Driver.php | 11 +++++------ Library/Think/Db/Driver/Sqlsrv.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Library/Think/Db/Driver.php b/Library/Think/Db/Driver.php index 59ec35b8..2cf31e5c 100644 --- a/Library/Think/Db/Driver.php +++ b/Library/Think/Db/Driver.php @@ -144,13 +144,12 @@ abstract class Driver { E($this->error()); foreach ($bind as $key => $val) { if(is_array($val)){ - $this->PDOStatement->bindParam($key, $val[0], $val[1]); + $this->PDOStatement->bindValue($key, $val[0], $val[1]); }else{ - $this->PDOStatement->bindParam($key, $val); + $this->PDOStatement->bindValue($key, $val); } } - $result = $this->PDOStatement->execute(); - //$result = $this->PDOStatement->execute($bind); + $result = $this->PDOStatement->execute(); // 调试结束 $this->debug(false); if ( false === $result ) { @@ -186,9 +185,9 @@ abstract class Driver { } foreach ($bind as $key => $val) { if(is_array($val)){ - $this->PDOStatement->bindParam($key, $val[0], $val[1]); + $this->PDOStatement->bindValue($key, $val[0], $val[1]); }else{ - $this->PDOStatement->bindParam($key, $val); + $this->PDOStatement->bindValue($key, $val); } } $result = $this->PDOStatement->execute(); diff --git a/Library/Think/Db/Driver/Sqlsrv.php b/Library/Think/Db/Driver/Sqlsrv.php index f567d9ea..80e73fa8 100644 --- a/Library/Think/Db/Driver/Sqlsrv.php +++ b/Library/Think/Db/Driver/Sqlsrv.php @@ -160,4 +160,4 @@ class Sqlsrv extends Driver{ return $this->execute($sql,$this->parseBind(!empty($options['bind'])?$options['bind']:[])); } -} +} \ No newline at end of file