Compare commits

..

No commits in common. "b9bf831001fbe15574394fad1b472d739551fa61" and "6ce3d646493c4bb555f66f8b476eedb4bc40a44d" have entirely different histories.

2 changed files with 12 additions and 8 deletions

View File

@ -1,5 +1,3 @@
DROP DATABASE IF EXISTS `products`;
CREATE DATABASE `products`;
USE `products`;
@ -11,7 +9,7 @@ CREATE TABLE `product` (
`sku` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sku` (`sku`)
);
)
CREATE TABLE `book` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
@ -20,7 +18,7 @@ CREATE TABLE `book` (
PRIMARY KEY (`id`),
UNIQUE KEY `book_UN` (`product_id`),
CONSTRAINT `book_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
);
)
CREATE TABLE `dvd` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
@ -29,7 +27,7 @@ CREATE TABLE `dvd` (
PRIMARY KEY (`id`),
UNIQUE KEY `dvd_UN` (`product_id`),
CONSTRAINT `dvd_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
);
)
CREATE TABLE `furniture` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
@ -40,4 +38,5 @@ CREATE TABLE `furniture` (
PRIMARY KEY (`id`),
UNIQUE KEY `furniture_UN` (`product_id`),
CONSTRAINT `furniture_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`)
);
)

View File

@ -8,10 +8,15 @@ define("FURNITURE", "furniture");
class Database
{
const SERVERNAME = "127.0.0.1";
const DATABASE = "scandiweb";
const USERNAME = "root";
const PASSWORD = "root";
public static function connect()
{
$conn = new \mysqli(getenv('SERVERNAME'), getenv('USERNAME'), getenv('PASSWORD'));
$conn->select_db(getenv('DATABASE'));
$conn = new \mysqli(self::SERVERNAME, self::USERNAME, self::PASSWORD);
$conn->select_db(self::DATABASE);
return $conn;
}
}