Bugfixing

This commit is contained in:
color.diff=auto 2021-03-26 16:04:42 -06:00
parent 855a1a4ba6
commit 70e09747e3

View File

@ -28,8 +28,9 @@ class D2Database {
public function createTables($file, $data) {
$tableName = basename($file);
$tableName = strtolower(substr($tableName, 0, -4));
$sql = "CREATE TABLE IF NOT EXISTS `$tableName` (";
if (!empty($data)) {
$sql = '';
if (!empty($data[0])) {
$sql = "CREATE TABLE IF NOT EXISTS `$tableName` (";
foreach ($data[0] as $k => $v) {
if (is_numeric($v)) {
$dataType = "INT";
@ -38,10 +39,10 @@ class D2Database {
}
$sql .= "`$k` $dataType NOT NULL,";
}
$sql = rtrim($sql, ",");
$sql .= ")";
$res = PDO_Execute($sql);
}
$sql = rtrim($sql, ",");
$sql .= ")";
$res = PDO_Execute($sql);
}
public function fillsTables($file, $data) {
@ -62,8 +63,9 @@ class D2Database {
}
}
}
$sql .= "VALUES ";
if (!empty($data)) {
$sql .= "VALUES ";
foreach ($data as $d) {
if (!empty($d)) {
$sql .= "(";
@ -75,6 +77,10 @@ class D2Database {
}
}
$sql = rtrim($sql, ", ");
var_dump($file);
var_dump($sql);
PDO_Execute($sql);
}
}