From 2b55eb78946a73c23cc7a8cfe9f314f22a1ad9e4 Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Thu, 13 Jun 2024 01:43:32 +0200 Subject: [PATCH 1/2] added mysql database value to dotenv --- .env.example | 5 +++++ public/util/mysql_connect.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ed5c22d --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +MYSQL_PORT= +MYSQL_USER= +MYSQL_PASSWORD= +MYSQL_DATABASE= +RIOT_API_KEY= \ No newline at end of file diff --git a/public/util/mysql_connect.php b/public/util/mysql_connect.php index d29b3a5..8e0fb33 100644 --- a/public/util/mysql_connect.php +++ b/public/util/mysql_connect.php @@ -8,7 +8,7 @@ class MySQLConnection { private string $host; private string $user; private string $pass; - private string $dbName = "uem"; + private string $dbName; private mysqli $mysqli; public function __construct() { @@ -16,6 +16,7 @@ class MySQLConnection { $this->port = intval($_ENV['MYSQL_PORT']); $this->user = $_ENV['MYSQL_USER']; $this->pass = $_ENV['MYSQL_PASSWORD']; + $this->dbName = $_ENV['MYSQL_DATABASE']; $this->createConn(); } From 12faaba75e54ebc5fa66adc5fbd8ac9308a14e53 Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Thu, 13 Jun 2024 01:47:12 +0200 Subject: [PATCH 2/2] db structure --- structure.sql | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 structure.sql diff --git a/structure.sql b/structure.sql new file mode 100644 index 0000000..ec2ccc8 --- /dev/null +++ b/structure.sql @@ -0,0 +1,84 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: localhost +-- Generation Time: Jun 13, 2024 at 01:45 AM +-- Server version: 8.0.36-0ubuntu0.22.04.1 +-- PHP Version: 8.1.29 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + +-- +-- Database: `uem` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `accounts` +-- + +CREATE TABLE `accounts` ( + `id` smallint NOT NULL, + `puuid` varchar(78) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL, + `gameName` varchar(32) NOT NULL, + `tagLine` varchar(16) NOT NULL, + `profileIconId` int NOT NULL DEFAULT '0' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `elo_entries` +-- + +CREATE TABLE `elo_entries` ( + `accountId` smallint NOT NULL, + `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `tier` enum('IRON','BRONZE','SILVER','GOLD','PLATINUM','EMERALD','DIAMOND','MASTER','GRANDMASTER','CHALLENGER') NOT NULL, + `rank` enum('I','II','III','IV') NOT NULL, + `points` smallint NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `accounts` +-- +ALTER TABLE `accounts` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `RiotID` (`gameName`,`tagLine`) USING BTREE, + ADD UNIQUE KEY `puuid` (`puuid`); + +-- +-- Indexes for table `elo_entries` +-- +ALTER TABLE `elo_entries` + ADD PRIMARY KEY (`accountId`,`date`), + ADD KEY `date` (`date`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `accounts` +-- +ALTER TABLE `accounts` + MODIFY `id` smallint NOT NULL AUTO_INCREMENT; + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `elo_entries` +-- +ALTER TABLE `elo_entries` + ADD CONSTRAINT `elo_entries_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; +COMMIT;