From b711c17bd27587d6577197dac12bad00dedd13fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9=E6=B3=89?= <80071319@qq.com> Date: Tue, 10 Dec 2019 23:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=8F=92=E5=85=A5=E6=95=B0=E6=8D=AEBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function/db.class.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/function/db.class.php b/function/db.class.php index 900b413..2427e8e 100644 --- a/function/db.class.php +++ b/function/db.class.php @@ -103,13 +103,16 @@ class db $return = $this->query('SHOW FULL COLUMNS FROM ' . $table); while ($info = $return->fetch_assoc()) { - if ($info['Field'] == 'ID' or $info['Field'] == 'id' or $info['Field'] == 'Id' or $info['Field'] == 'iD') { - $data[$info['Field']] = '{nullvaluereplace}'; - } else if (stristr($info['Type'], 'int') || stristr($info['Type'], 'bigint') || stristr($info['Type'], 'integer') || stristr($info['Type'], 'double')) { - $data[$info['Field']] = '{intvaluereplace}'; - } else { - $data[$info['Field']] = ''; - } + if(empty($data[$info['Field']]) ){ + if ($info['Field'] == 'ID' or $info['Field'] == 'id' or $info['Field'] == 'Id' or $info['Field'] == 'iD') { + $data[$info['Field']] = '{nullvaluereplace}'; + } else if (stristr($info['Type'], 'int') || stristr($info['Type'], 'bigint') || stristr($info['Type'], 'integer') || stristr($info['Type'], 'double')) { + $data[$info['Field']] = '{intvaluereplace}'; + } else { + $data[$info['Field']] = ''; + } + } + } $column = ''; $value = ''; @@ -122,7 +125,11 @@ class db } else if ($v == '{intvaluereplace}') { $value = '0'; } else { - $value = '\'' . addslashes($v) . '\''; + if(is_int($v) || is_float($v) || is_double($v)){ + $value = $v ; + }else{ + $value = '\'' . addslashes($v) . '\''; + } } } else { $column .= ',' . $k; @@ -131,7 +138,12 @@ class db } else if ($v == '{intvaluereplace}') { $value .= ',0'; } else { - $value .= ',\'' . addslashes($v) . '\''; + if(is_int($v) || is_float($v) || is_double($v)){ + $value .= ', ' . addslashes($v) ; + }else{ + $value .= ', \'' . addslashes($v) . '\''; + } + } }