From 4b429c242934dd0ac7ccaffbc57de84c76a6b3c2 Mon Sep 17 00:00:00 2001 From: kemasama Date: Sun, 22 May 2022 11:40:31 +0900 Subject: [PATCH] init --- .gitignore | 3 ++ config.sample.php | 12 ++++++++ index.php | 4 +++ provide/ClassLoader.php | 57 ++++++++++++++++++++++++++++++++++++ provide/autoload.php | 23 +++++++++++++++ provide/classes/IDB.php | 23 +++++++++++++++ provide/classes/Timecard.php | 15 ++++++++++ 7 files changed, 137 insertions(+) create mode 100644 .gitignore create mode 100644 config.sample.php create mode 100644 index.php create mode 100644 provide/ClassLoader.php create mode 100644 provide/autoload.php create mode 100644 provide/classes/IDB.php create mode 100644 provide/classes/Timecard.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a10944 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config.php + + diff --git a/config.sample.php b/config.sample.php new file mode 100644 index 0000000..1952994 --- /dev/null +++ b/config.sample.php @@ -0,0 +1,12 @@ + [ + "hostname" => "localhost", + "dbname" => "timecard", + "username" => "root", + "password" => "" + ], + + "canonical" => "http://localhost/timecard/", +]; diff --git a/index.php b/index.php new file mode 100644 index 0000000..1a1f583 --- /dev/null +++ b/index.php @@ -0,0 +1,4 @@ +Connect($config["mysql"]["hostname"], + $config["mysql"]["dbname"], + $config["mysql"]["username"], + $config["mysql"]["password"]) +) +{ + echo 'can not connect to mysql server.'; + exit; +} + +$pdo = $db->getDB(); diff --git a/provide/classes/IDB.php b/provide/classes/IDB.php new file mode 100644 index 0000000..327356b --- /dev/null +++ b/provide/classes/IDB.php @@ -0,0 +1,23 @@ +pdo = null; + } + + private $pdo; + + public function Connect($host, $name, $user, $pass) { + try { + $this->pdo = new PDO("mysql:dbname=" . $name . ";host=" . $host, $user, $pass); + return true; + } catch (PDOException $e) { + return false; + } + } + + public function getDB() { + return $this->pdo; + } +} + diff --git a/provide/classes/Timecard.php b/provide/classes/Timecard.php new file mode 100644 index 0000000..ee42884 --- /dev/null +++ b/provide/classes/Timecard.php @@ -0,0 +1,15 @@ +pdo = $pdo; + } + + protected $pdo; + + public function InsertTime() + { + } +}