修复数据库插入数据BUG
This commit is contained in:
+21
-9
@@ -103,13 +103,16 @@ class db
|
|||||||
|
|
||||||
$return = $this->query('SHOW FULL COLUMNS FROM ' . $table);
|
$return = $this->query('SHOW FULL COLUMNS FROM ' . $table);
|
||||||
while ($info = $return->fetch_assoc()) {
|
while ($info = $return->fetch_assoc()) {
|
||||||
if ($info['Field'] == 'ID' or $info['Field'] == 'id' or $info['Field'] == 'Id' or $info['Field'] == 'iD') {
|
if(empty($data[$info['Field']]) ){
|
||||||
$data[$info['Field']] = '{nullvaluereplace}';
|
if ($info['Field'] == 'ID' or $info['Field'] == 'id' or $info['Field'] == 'Id' or $info['Field'] == 'iD') {
|
||||||
} else if (stristr($info['Type'], 'int') || stristr($info['Type'], 'bigint') || stristr($info['Type'], 'integer') || stristr($info['Type'], 'double')) {
|
$data[$info['Field']] = '{nullvaluereplace}';
|
||||||
$data[$info['Field']] = '{intvaluereplace}';
|
} else if (stristr($info['Type'], 'int') || stristr($info['Type'], 'bigint') || stristr($info['Type'], 'integer') || stristr($info['Type'], 'double')) {
|
||||||
} else {
|
$data[$info['Field']] = '{intvaluereplace}';
|
||||||
$data[$info['Field']] = '';
|
} else {
|
||||||
}
|
$data[$info['Field']] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$column = '';
|
$column = '';
|
||||||
$value = '';
|
$value = '';
|
||||||
@@ -122,7 +125,11 @@ class db
|
|||||||
} else if ($v == '{intvaluereplace}') {
|
} else if ($v == '{intvaluereplace}') {
|
||||||
$value = '0';
|
$value = '0';
|
||||||
} else {
|
} else {
|
||||||
$value = '\'' . addslashes($v) . '\'';
|
if(is_int($v) || is_float($v) || is_double($v)){
|
||||||
|
$value = $v ;
|
||||||
|
}else{
|
||||||
|
$value = '\'' . addslashes($v) . '\'';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$column .= ',' . $k;
|
$column .= ',' . $k;
|
||||||
@@ -131,7 +138,12 @@ class db
|
|||||||
} else if ($v == '{intvaluereplace}') {
|
} else if ($v == '{intvaluereplace}') {
|
||||||
$value .= ',0';
|
$value .= ',0';
|
||||||
} else {
|
} else {
|
||||||
$value .= ',\'' . addslashes($v) . '\'';
|
if(is_int($v) || is_float($v) || is_double($v)){
|
||||||
|
$value .= ', ' . addslashes($v) ;
|
||||||
|
}else{
|
||||||
|
$value .= ', \'' . addslashes($v) . '\'';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user