Bugfixing

This commit is contained in:
color.diff=auto 2021-03-26 15:44:33 -06:00
parent 358666c292
commit 1fd9f2165a
2 changed files with 34 additions and 28 deletions

View File

@ -17,6 +17,7 @@ if (file_exists("d2im.db")) {
$db->fillsTables($k, $v); $db->fillsTables($k, $v);
} }
} }
die();
// put in html redirect as backup, because // put in html redirect as backup, because
// for some odd reason windows gives // for some odd reason windows gives
// an error on header() but linux does not. // an error on header() but linux does not.

View File

@ -29,6 +29,7 @@ class D2Database {
$tableName = basename($file); $tableName = basename($file);
$tableName = strtolower(substr($tableName, 0, -4)); $tableName = strtolower(substr($tableName, 0, -4));
$sql = "CREATE TABLE IF NOT EXISTS `$tableName` ("; $sql = "CREATE TABLE IF NOT EXISTS `$tableName` (";
if (!empty($data)) {
foreach ($data[0] as $k => $v) { foreach ($data[0] as $k => $v) {
if (is_numeric($v)) { if (is_numeric($v)) {
$dataType = "INT"; $dataType = "INT";
@ -37,6 +38,7 @@ class D2Database {
} }
$sql .= "`$k` $dataType NOT NULL,"; $sql .= "`$k` $dataType NOT NULL,";
} }
}
$sql = rtrim($sql, ","); $sql = rtrim($sql, ",");
$sql .= ")"; $sql .= ")";
$res = PDO_Execute($sql); $res = PDO_Execute($sql);
@ -47,6 +49,7 @@ class D2Database {
$tableName = strtolower(substr($tableName, 0, -4)); $tableName = strtolower(substr($tableName, 0, -4));
$sql = ''; $sql = '';
if (!empty($data)) {
foreach ($data as $d) { foreach ($data as $d) {
$sql = "INSERT INTO `$tableName` ("; $sql = "INSERT INTO `$tableName` (";
if (!empty($d)) { if (!empty($d)) {
@ -57,9 +60,9 @@ class D2Database {
$sql = rtrim($sql, ","); $sql = rtrim($sql, ",");
$sql .= ") "; $sql .= ") ";
} }
}
$sql .= "VALUES "; $sql .= "VALUES ";
if (!empty($data)) {
foreach ($data as $d) { foreach ($data as $d) {
$sql .= "("; $sql .= "(";
@ -74,4 +77,6 @@ class D2Database {
$sql = rtrim($sql, ", "); $sql = rtrim($sql, ", ");
PDO_Execute($sql); PDO_Execute($sql);
} }
}
} }