don #2
@ -6,7 +6,7 @@ time_zone = "+00:00";
|
|||||||
|
|
||||||
CREATE TABLE `ingredienti`
|
CREATE TABLE `ingredienti`
|
||||||
( /*Zutaten*/
|
( /*Zutaten*/
|
||||||
`id` varchar(36) NOT NULL,
|
`id` int auto_increment NOT NULL PRIMARY KEY,
|
||||||
`cognome` varchar(200) NOT NULL, /*Name*/
|
`cognome` varchar(200) NOT NULL, /*Name*/
|
||||||
`caloriePerCento` integer(5) NOT NULL, /*Kalorien pro Gramm*/
|
`caloriePerCento` integer(5) NOT NULL, /*Kalorien pro Gramm*/
|
||||||
`ilPeso` integer(5) NULL, /*Gewicht*/
|
`ilPeso` integer(5) NULL, /*Gewicht*/
|
||||||
@ -16,14 +16,14 @@ CREATE TABLE `ingredienti`
|
|||||||
|
|
||||||
CREATE TABLE `folla`
|
CREATE TABLE `folla`
|
||||||
( /*Menge*/
|
( /*Menge*/
|
||||||
`id` varchar(36) NOT NULL,
|
`id` int auto_increment NOT NULL PRIMARY KEY,
|
||||||
`unita` varchar(200) NOT NULL, /*Einheit*/
|
`unita` varchar(200) NOT NULL, /*Einheit*/
|
||||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE `elenco`
|
CREATE TABLE `elenco`
|
||||||
( /*Liste*/
|
( /*Liste*/
|
||||||
`id` varchar(36) NOT NULL,
|
`id` int auto_increment NOT NULL PRIMARY KEY,
|
||||||
`creatore` varchar(200) NOT NULL, /*Ersteller*/
|
`creatore` varchar(200) NOT NULL, /*Ersteller*/
|
||||||
`coloreDiSfondo` integer(10) NOT NULL, /*Hintergrundfarbe*/
|
`coloreDiSfondo` integer(10) NOT NULL, /*Hintergrundfarbe*/
|
||||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
@ -31,50 +31,36 @@ CREATE TABLE `elenco`
|
|||||||
|
|
||||||
CREATE TABLE `utente`
|
CREATE TABLE `utente`
|
||||||
( /*Benutzer*/
|
( /*Benutzer*/
|
||||||
`id` varchar(36) NOT NULL,
|
`id` int auto_increment NOT NULL PRIMARY KEY,
|
||||||
`email` varchar(200) NOT NULL, /*Email*/
|
`email` varchar(200) NOT NULL, /*Email*/
|
||||||
`parolaDordine` varchar(255) NOT NULL, /*Passwort*/
|
`parolaDordine` varchar(255) NOT NULL, /*Passwort*/
|
||||||
`nomeUtente` varchar(50) UNIQUE NOT NULL, /*Benutzernamen*/
|
`nomeUtente` varchar(50) UNIQUE NOT NULL, /*Benutzernamen*/
|
||||||
`gettone` varchar(255), /*Token für Session*/
|
`gettone` varchar(255), /*Token für Session*/
|
||||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE `elencoIngredienti`
|
CREATE TABLE `elencoIngredienti`
|
||||||
( /*Liste_Zutaten*/
|
( /*Liste_Zutaten*/
|
||||||
`id` varchar(36) NOT NULL,
|
`id` int auto_increment NOT NULL PRIMARY KEY,
|
||||||
`ingredientiID` varchar(36) NOT NULL, /*ZutatenID*/
|
`ingredientiID` int NOT NULL, /*ZutatenID*/
|
||||||
`elencoID` varchar(36) NOT NULL, /*ListeID*/
|
`elencoID` int NOT NULL, /*ListeID*/
|
||||||
`follaID` varchar(36) NOT NULL, /*MengeID*/
|
`follaID` int NOT NULL, /*MengeID*/
|
||||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE `utenteElenco`
|
CREATE TABLE `utenteElenco`
|
||||||
( /*Benutzer_Liste*/
|
( /*Benutzer_Liste*/
|
||||||
`id` varchar(36) NOT NULL,
|
`id` int auto_increment NOT NULL PRIMARY KEY,
|
||||||
`elencoID` varchar(36) NOT NULL, /*ListeID*/
|
`elencoID` int NOT NULL, /*ListeID*/
|
||||||
`utenteID` varchar(36) NOT NULL, /*BenutzerID*/
|
`utenteID` int NOT NULL, /*BenutzerID*/
|
||||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
ALTER TABLE `ingredienti` /*Zutaten*/
|
|
||||||
ADD PRIMARY KEY (`id`);
|
|
||||||
|
|
||||||
ALTER TABLE `folla` /*Menge*/
|
|
||||||
ADD PRIMARY KEY (`id`);
|
|
||||||
|
|
||||||
ALTER TABLE `elenco` /*Liste*/
|
|
||||||
ADD PRIMARY KEY (`id`);
|
|
||||||
|
|
||||||
ALTER TABLE `utente` /*Benutzer*/
|
|
||||||
ADD PRIMARY KEY (`id`);
|
|
||||||
|
|
||||||
ALTER TABLE `elencoIngredienti` /*Liste_Zutaten*/
|
ALTER TABLE `elencoIngredienti` /*Liste_Zutaten*/
|
||||||
ADD PRIMARY KEY (`id`),
|
|
||||||
ADD CONSTRAINT `FK_ElencoIngredienti_Ingredienti` FOREIGN KEY (`ingredientiID`) REFERENCES `ingredienti`(`id`), /*Liste_Zutaten hat Foreignkey von Zutaten(id)*/
|
ADD CONSTRAINT `FK_ElencoIngredienti_Ingredienti` FOREIGN KEY (`ingredientiID`) REFERENCES `ingredienti`(`id`), /*Liste_Zutaten hat Foreignkey von Zutaten(id)*/
|
||||||
ADD CONSTRAINT `FK_ElencoIngredienti_Elenco` FOREIGN KEY (`elencoID`) REFERENCES `elenco`(`id`), /*Liste_Zutaten hat Foreignkey von Liste(id)*/
|
ADD CONSTRAINT `FK_ElencoIngredienti_Elenco` FOREIGN KEY (`elencoID`) REFERENCES `elenco`(`id`), /*Liste_Zutaten hat Foreignkey von Liste(id)*/
|
||||||
ADD CONSTRAINT `FK_ElencoIngredienti_Folla` FOREIGN KEY (`follaID`) REFERENCES `folla`(`id`); /*Liste_Zutaten hat Foreignkey von Menge(id)*/
|
ADD CONSTRAINT `FK_ElencoIngredienti_Folla` FOREIGN KEY (`follaID`) REFERENCES `folla`(`id`); /*Liste_Zutaten hat Foreignkey von Menge(id)*/
|
||||||
|
|
||||||
ALTER TABLE `utenteElenco` /*Benutzer_Liste*/
|
ALTER TABLE `utenteElenco` /*Benutzer_Liste*/
|
||||||
ADD PRIMARY KEY (`id`),
|
|
||||||
ADD CONSTRAINT `FK_UtenteElenco_Utente` FOREIGN KEY (`utenteId`) REFERENCES `utente`(`id`), /*Benutzer_Liste hat Foreignkey von Benutzer(id)*/
|
ADD CONSTRAINT `FK_UtenteElenco_Utente` FOREIGN KEY (`utenteId`) REFERENCES `utente`(`id`), /*Benutzer_Liste hat Foreignkey von Benutzer(id)*/
|
||||||
ADD CONSTRAINT `FK_UtenteElenco_Elenco` FOREIGN KEY (`elencoId`) REFERENCES `elenco`(`id`); /*Benutzer_Liste hat Foreignkey von Liste(id)*/
|
ADD CONSTRAINT `FK_UtenteElenco_Elenco` FOREIGN KEY (`elencoId`) REFERENCES `elenco`(`id`); /*Benutzer_Liste hat Foreignkey von Liste(id)*/
|
||||||
|
@ -100,16 +100,23 @@ class BancaDati {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function select(string $table, array $data, array $order = null){
|
* einheitliche Select Funktion
|
||||||
$where = "";
|
* @param string $table
|
||||||
foreach ($data as $col => $v) {
|
* @param array $where ["column"]=>"value" es wird mit LIKE verglichen und mit AND verbunden
|
||||||
if($where != ""){
|
* @param array|null $order ["by"]=>"column"; ["order"]=>"ASC|DESC"
|
||||||
$where .= " AND ";
|
* @return void
|
||||||
|
* @author Malte Schulze Hobeling
|
||||||
|
*/
|
||||||
|
public function select(string $table, array $where, array $order = null){
|
||||||
|
$whereString = "";
|
||||||
|
foreach ($where as $col => $v) {
|
||||||
|
if($whereString != ""){
|
||||||
|
$whereString .= " AND ";
|
||||||
}
|
}
|
||||||
$where .= $col . "=" . $v;
|
$whereString .= $col . " LIKE " . $v;
|
||||||
}
|
}
|
||||||
$sql = "SELECT * FROM ".$table." WHERE ".$where;
|
$sql = "SELECT * FROM ".$table." WHERE ".$whereString;
|
||||||
if(isset($order["by"])){
|
if(isset($order["by"])){
|
||||||
$sql .= " ORDER BY ".$order["by"];
|
$sql .= " ORDER BY ".$order["by"];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user