From 855a1a4ba603fd2e487064d4ceef3266af616ecd Mon Sep 17 00:00:00 2001 From: "color.diff=auto" Date: Fri, 26 Mar 2021 15:52:19 -0600 Subject: [PATCH] Bugfixing --- src/D2Database.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/D2Database.php b/src/D2Database.php index b228605..d09eccc 100644 --- a/src/D2Database.php +++ b/src/D2Database.php @@ -51,28 +51,28 @@ class D2Database { $sql = ''; if (!empty($data)) { foreach ($data as $d) { - $sql = "INSERT INTO `$tableName` ("; + if (!empty($d)) { + $sql = "INSERT INTO `$tableName` ("; foreach ($d as $k => $v) { $sql .= "`$k`" . ","; } + $sql = rtrim($sql, ","); + $sql .= ") "; } - $sql = rtrim($sql, ","); - $sql .= ") "; } } $sql .= "VALUES "; if (!empty($data)) { foreach ($data as $d) { - $sql .= "("; - if (!empty($d)) { + $sql .= "("; foreach ($d as $k => $v) { $sql .= '"' . $v . '"' . ","; } + $sql = rtrim($sql, ","); + $sql .= "), "; } - $sql = rtrim($sql, ","); - $sql .= "), "; } $sql = rtrim($sql, ", "); PDO_Execute($sql);