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);
}
}
die();
// put in html redirect as backup, because
// for some odd reason windows gives
// an error on header() but linux does not.

View File

@ -29,13 +29,15 @@ class D2Database {
$tableName = basename($file);
$tableName = strtolower(substr($tableName, 0, -4));
$sql = "CREATE TABLE IF NOT EXISTS `$tableName` (";
foreach ($data[0] as $k => $v) {
if (is_numeric($v)) {
$dataType = "INT";
} else {
$dataType = "VARCHAR(255)";
if (!empty($data)) {
foreach ($data[0] as $k => $v) {
if (is_numeric($v)) {
$dataType = "INT";
} else {
$dataType = "VARCHAR(255)";
}
$sql .= "`$k` $dataType NOT NULL,";
}
$sql .= "`$k` $dataType NOT NULL,";
}
$sql = rtrim($sql, ",");
$sql .= ")";
@ -47,31 +49,34 @@ class D2Database {
$tableName = strtolower(substr($tableName, 0, -4));
$sql = '';
foreach ($data as $d) {
$sql = "INSERT INTO `$tableName` (";
if (!empty($d)) {
foreach ($d as $k => $v) {
$sql .= "`$k`" . ",";
if (!empty($data)) {
foreach ($data as $d) {
$sql = "INSERT INTO `$tableName` (";
if (!empty($d)) {
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 .= "(";
foreach ($data as $d) {
$sql .= "(";
if (!empty($d)) {
foreach ($d as $k => $v) {
$sql .= '"' . $v . '"' . ",";
if (!empty($d)) {
foreach ($d as $k => $v) {
$sql .= '"' . $v . '"' . ",";
}
}
$sql = rtrim($sql, ",");
$sql .= "), ";
}
$sql = rtrim($sql, ",");
$sql .= "), ";
$sql = rtrim($sql, ", ");
PDO_Execute($sql);
}
$sql = rtrim($sql, ", ");
PDO_Execute($sql);
}
}