Compare commits

10 Commits

3 changed files with 47 additions and 33 deletions

View File

@@ -6,7 +6,7 @@ time_zone = "+00:00";
CREATE TABLE `ingredienti`
( /*Zutaten*/
`id` varchar(36) NOT NULL,
`id` int auto_increment NOT NULL PRIMARY KEY,
`cognome` varchar(200) NOT NULL, /*Name*/
`caloriePerCento` integer(5) NOT NULL, /*Kalorien pro Gramm*/
`ilPeso` integer(5) NULL, /*Gewicht*/
@@ -16,14 +16,14 @@ CREATE TABLE `ingredienti`
CREATE TABLE `folla`
( /*Menge*/
`id` varchar(36) NOT NULL,
`id` int auto_increment NOT NULL PRIMARY KEY,
`unita` varchar(200) NOT NULL, /*Einheit*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `elenco`
( /*Liste*/
`id` varchar(36) NOT NULL,
`id` int auto_increment NOT NULL PRIMARY KEY,
`creatore` varchar(200) NOT NULL, /*Ersteller*/
`coloreDiSfondo` integer(10) NOT NULL, /*Hintergrundfarbe*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
@@ -31,7 +31,7 @@ CREATE TABLE `elenco`
CREATE TABLE `utente`
( /*Benutzer*/
`id` varchar(36) NOT NULL,
`id` int auto_increment NOT NULL PRIMARY KEY,
`email` varchar(200) NOT NULL, /*Email*/
`parolaDordine` varchar(255) NOT NULL, /*Passwort*/
`nomeUtente` varchar(50) UNIQUE NOT NULL, /*Benutzernamen*/
@@ -41,40 +41,26 @@ CREATE TABLE `utente`
CREATE TABLE `elencoIngredienti`
( /*Liste_Zutaten*/
`id` varchar(36) NOT NULL,
`ingredientiID` varchar(36) NOT NULL, /*ZutatenID*/
`elencoID` varchar(36) NOT NULL, /*ListeID*/
`follaID` varchar(36) NOT NULL, /*MengeID*/
`id` int auto_increment NOT NULL PRIMARY KEY,
`ingredientiID` int NOT NULL, /*ZutatenID*/
`elencoID` int NOT NULL, /*ListeID*/
`follaID` int NOT NULL, /*MengeID*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `utenteElenco`
( /*Benutzer_Liste*/
`id` varchar(36) NOT NULL,
`elencoID` varchar(36) NOT NULL, /*ListeID*/
`utenteID` varchar(36) NOT NULL, /*BenutzerID*/
`id` int auto_increment NOT NULL PRIMARY KEY,
`elencoID` int NOT NULL, /*ListeID*/
`utenteID` int NOT NULL, /*BenutzerID*/
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) 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*/
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_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)*/
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_Elenco` FOREIGN KEY (`elencoId`) REFERENCES `elenco`(`id`); /*Benutzer_Liste hat Foreignkey von Liste(id)*/

View File

@@ -44,7 +44,7 @@ class BancaDati {
$value = "";
$column = "";
foreach ($values as $col => $v){
$value .= $v . ",";
$value .= "'" . $v . "',";
$column .= $col . ",";
}
$value = trim($value, ",");
@@ -70,7 +70,7 @@ class BancaDati {
public function update(string $table, string $id, array $values){
$value = "";
foreach ($values as $col => $v){
$value .= $col . "=" . $v . ",";
$value .= $col . "='" . $v . "',";
}
$value = trim($value, ",");
@@ -91,7 +91,7 @@ class BancaDati {
* @author Malte Schulze Hobeling
*/
public function delete(string $table, string $id){
$sql = "DELETE FROM " . $table . " WHERE `id` = " . $id . ";";
$sql = "DELETE FROM " . $table . " WHERE `id` = '" . $id . "';";
try {
$sth = $this->pdo->prepare($sql);
$sth->execute();
@@ -114,9 +114,9 @@ class BancaDati {
if($whereString != ""){
$whereString .= " AND ";
}
$whereString .= $col . " LIKE " . $v;
$whereString .= "`" . $col . "` = '" . $v . "'";
}
$sql = "SELECT * FROM ".$table." WHERE ".$whereString;
$sql = "SELECT * FROM ".$table." WHERE ".$whereString.";";
if(isset($order["by"])){
$sql .= " ORDER BY ".$order["by"];
}
@@ -124,6 +124,7 @@ class BancaDati {
$sql .= $order["order"];
}
try {
var_dump($sql);
return $this->pdo->query($sql);
}catch (PDOException $e){
die;

27
italienIntoGerman.txt Normal file
View File

@@ -0,0 +1,27 @@
ingredienti = Zutaten
cognome = Name
caloriePerCento = Kalorien pro Gramm
ilPeso = Gewicht
prezzo = Preis
folla = Menge
unita = Einheit
elenco = Liste
creatore = Ersteller
coloreDiSfondo = Hintergrundfarbe
utente = Benutzer
email = Email
parolaDordine = Passwort
nomeUtente = Benutzernamen
gettone = Token (für die Session)
elencoIngredienti = Liste_Zutaten
ingredientiID = ZutatenID
elencoID = ListeID
follaID = MengeID
utenteElenco = Benutzer_Liste
elencoID = ListeID
utenteID = BenutzerID