From f2e51604f4019811aa19e94ffaef26b0a42d37fe Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 17 Oct 2016 12:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=95=B4=E5=9E=8B=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E5=8F=82=E6=95=B0=E7=BB=91=E5=AE=9A=E5=86=99?= =?UTF-8?q?=E5=85=A5=20=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index f405f9b9..f39ca341 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -421,6 +421,8 @@ abstract class Connection $type = is_array($val) ? $val[1] : PDO::PARAM_STR; if (PDO::PARAM_STR == $type) { $value = $this->quote($value); + } elseif (PDO::PARAM_INT == $type && '' === $value) { + $value = 0; } // 判断占位符 $sql = is_numeric($key) ? @@ -449,6 +451,9 @@ abstract class Connection // 占位符 $param = is_numeric($key) ? $key + 1 : ':' . $key; if (is_array($val)) { + if (PDO::PARAM_INT == $val[1] && '' === $val[0]) { + $val[0] = 0; + } $result = $this->PDOStatement->bindValue($param, $val[0], $val[1]); } else { $result = $this->PDOStatement->bindValue($param, $val);