diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..60140e1
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,10 @@
+{
+ "require": {
+ "vlucas/phpdotenv": "^5.6"
+ },
+ "autoload": {
+ "psr-4": {
+ "lib\\": "lib/"
+ }
+ }
+}
\ No newline at end of file
diff --git a/extdbms/index.php b/extdbms/index.php
index ff99753..fbd8c4c 100644
--- a/extdbms/index.php
+++ b/extdbms/index.php
@@ -1,16 +1,17 @@
load();
- $control = new SiteController();
- return $control->dashboard();
+ $control = new $control();
+ return $control->$function(isset($arvg[3]) ? $argv[3] : "dbms.prime-idc.jp");
} catch (\Exception $e) {
echo $e->getMessage();
}
diff --git a/extdbms/lib/Controllers/SiteController.php b/extdbms/lib/Controllers/SiteController.php
index 30aa6ed..2d9cf06 100644
--- a/extdbms/lib/Controllers/SiteController.php
+++ b/extdbms/lib/Controllers/SiteController.php
@@ -25,7 +25,7 @@ class SiteController extends CommonController
// 최근7일 신규서버수
//예외,service_line = "test","substitution"
$excepts = ["test", "substitution"];
- $this->day = intval(getenv("SITE_DASHBOARD_DAY") ?? 7);
+ $this->day = intval($_ENV['SITE_DASHBOARD_DAY'] ?? $_SERVER['SITE_DASHBOARD_DAY'] ?? 7);
$this->newServers = $this->getService()->getNewServerCount($this->day, $excepts);
// 금일기준 미납서버수
//예외,service_line = "test","substitution",C012:게임윙,C116:WinIDC,C219:IDC-JP
diff --git a/extdbms/lib/Core/Model.php b/extdbms/lib/Core/Model.php
index b6276ff..03564a7 100644
--- a/extdbms/lib/Core/Model.php
+++ b/extdbms/lib/Core/Model.php
@@ -25,8 +25,6 @@ abstract class Model
final public function getConnect(): PDO
{
if ($this->_db === null) {
- // $dsn = sprintf("%s:host=%s;dbname=%s;charset=%s", getenv('DATABASE_DRIVER'), getenv('DATABASE_HOST'), getenv('DATABASE_DB'), getenv('DATABASE_CHARSET'));
- // $this->_db = new PDO($dsn, getenv('DATABASE_ID'), getenv('DATABASE_PASSWORD'));
$driver = $_ENV['DATABASE_DRIVER'] ?? $_SERVER['DATABASE_DRIVER'] ?? 'mysql';
$host = $_ENV['DATABASE_HOST'] ?? $_SERVER['DATABASE_HOST'] ?? 'localhost';
$dbname = $_ENV['DATABASE_DB'] ?? $_SERVER['DATABASE_DB'] ?? 'test';
@@ -71,25 +69,25 @@ abstract class Model
}
return implode(",", $temps);
}
- final public function getData(mixed $columns, mixed $values = null, $delimeter = ","): string
+ final public function makeQuery(mixed $columns, mixed $values = null, $delimeter = ","): string
{
$temps = [];
if (is_array($columns)) {
foreach ($columns as $column => $value) {
$value = $this->getValue($value);
- $temps[] = $column . $value === null ? "" : $value;
+ $temps[] = sprintf("%s%s", $column, $value === null ? "" : "=" . $value);
}
} else {
$value = $this->getValue($values);
- $temps[] = $columns . $value === null ? "" : $value;
+ $temps[] = sprintf("%s%s", $columns, $value === null ? "" : "=" . $value);
}
// throw new \Exception("DATA:" . $columns . $value === null ? "NULL" : $value);
- // var_export($temps);
- return implode($delimeter, $temps);
+ return implode($delimeter . " ", $temps);
}
final public function where(mixed $columns, mixed $values = null, string $delimeter = "AND"): void
{
- $this->_wheres[] = $this->getData($columns, $values, $delimeter);
+ $query = $this->makeQuery($columns, $values, $delimeter);
+ $this->_wheres[] = count($this->_wheres) ? $delimeter . " " . $query : $query;
}
final public function orWhere(mixed $columns, mixed $values = null, string $delimeter = "OR"): void
{
@@ -126,12 +124,12 @@ abstract class Model
//CURD문
final protected function create_process(mixed $columns, mixed $values = null): bool|PDOStatement
{
- $query = sprintf("INSERT INTO %s VALUES(%s) %s", $this->getTable(), $this->getData($columns, $values), $this->getWhere());
+ $query = sprintf("INSERT INTO %s VALUES(%s) %s", $this->getTable(), $this->makeQuery($columns, $values), $this->getWhere());
return $this->execute($query);
} //
final protected function modify_process(mixed $columns, mixed $values = null): bool|PDOStatement
{
- $query = sprintf("UPDATE %s SET %s %s", $this->getTable(), $this->getData($columns, $values), $this->getWhere());
+ $query = sprintf("UPDATE %s SET %s %s", $this->getTable(), $this->makeQuery($columns, $values), $this->getWhere());
return $this->execute($query);
} //
final protected function delete_process(): bool|PDOStatement
@@ -149,7 +147,7 @@ abstract class Model
}
final public function orderBy(mixed $columns, mixed $direction = null): void
{
- $this->_querys["ORDERBY"] = " ORDERBY " . $this->getData($columns, $direction, " ");
+ $this->_querys["ORDERBY"] = " ORDERBY " . $this->makeQuery($columns, $direction, " ");
}
final public function limit(int $start, mixed $end = "", bool $offset = false): void
{
diff --git a/extdbms/lib/Services/ServiceService.php b/extdbms/lib/Services/ServiceService.php
index 6b248dc..b18e052 100644
--- a/extdbms/lib/Services/ServiceService.php
+++ b/extdbms/lib/Services/ServiceService.php
@@ -53,8 +53,8 @@ class ServiceService extends CommonService
$this->getModel()->where("service_status", 'o');
$this->getModel()->whereNotIn("service_line", $excepts);
$count = $this->getModel()->countAllResults();
- throw new \Exception("TEST");
- // echo "
" . $this->getModel()->getLastQuery();
+ // throw new \Exception($this->getModel()->getLastQuery());
+ echo __FUNCTION__ . ":" . $this->getModel()->getLastQuery();
return $count;
}
public function getUnPaymentCount(array $excepts): int|string
@@ -64,6 +64,7 @@ class ServiceService extends CommonService
$this->getModel()->whereNotIn("service_line", $excepts);
$count = $this->getModel()->countAllResults();
// throw new \Exception($this->getModel()->getLastQuery());
+ echo __FUNCTION__ . ":" . $this->getModel()->getLastQuery();
return $count;
}
diff --git a/extdbms/lib/View/total_counting.php b/extdbms/lib/View/totalcount.php
similarity index 89%
rename from extdbms/lib/View/total_counting.php
rename to extdbms/lib/View/totalcount.php
index 31a16b0..49bd9f5 100644
--- a/extdbms/lib/View/total_counting.php
+++ b/extdbms/lib/View/totalcount.php
@@ -1,4 +1,3 @@
-