linkDB(); $sql = "SELECT * FROM Standort ORDER BY standortid ASC;"; try { $sth = $pdo->prepare($sql); $sth->execute(); return $sth->fetchAll(\PDO::FETCH_ASSOC); } catch (PDOException $e) { new \Blog\Library\ErrorMsg("Fehler beim Lesen der Standorte.", $e); die; } } public function getStandort($standortid) { $pdo = $this->linkDB(); $sql = "SELECT * FROM Standort WHERE standortid = :standortid;"; $params = [":standortid" => $standortid]; try { $sth = $pdo->prepare($sql); $sth->execute($params); return $sth->fetch(\PDO::FETCH_ASSOC); } catch (PDOException $e) { new \Blog\Library\ErrorMsg("Fehler beim Lesen des Standorts.", $e); die; } } public function createStandort($data) { $pdo = $this->linkDB(); $sql = "INSERT INTO Standort (straße, hausnr, postleitzahl, ort, land, tel, email) VALUES (:straße, :hausnr, :postleitzahl, :ort, :land, :tel, :email);"; $params = [ ":straße" => $data['straße'], ":hausnr" => $data['hausnr'], ":postleitzahl" => $data['postleitzahl'], ":ort" => $data['ort'], ":land" => $data['land'], ":tel" => $data['tel'], ":email" => $data['email'] ]; try { $sth = $pdo->prepare($sql); $sth->execute($params); return $pdo->lastInsertId(); } catch (PDOException $e) { new \Blog\Library\ErrorMsg("Fehler beim Anlegen des Standorts.", $e); die; } } public function updateStandort($standortid, $data) { $pdo = $this->linkDB(); $sql = "UPDATE Standort SET straße = :straße, hausnr = :hausnr, postleitzahl = :postleitzahl, ort = :ort, land = :land, tel = :tel, email = :email WHERE standortid = :standortid;"; $params = [ ":straße" => $data['straße'], ":hausnr" => $data['hausnr'], ":postleitzahl" => $data['postleitzahl'], ":ort" => $data['ort'], ":land" => $data['land'], ":tel" => $data['tel'], ":email" => $data['email'], ":standortid" => $standortid ]; try { $sth = $pdo->prepare($sql); $sth->execute($params); return $sth->rowCount(); } catch (PDOException $e) { new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Standorts.", $e); die; } } public function deleteStandort($standortid) { $pdo = $this->linkDB(); $sql = "DELETE FROM Standort WHERE standortid = :standortid;"; $params = [":standortid" => $standortid]; try { $sth = $pdo->prepare($sql); $sth->execute($params); return $sth->rowCount(); } catch (PDOException $e) { new \Blog\Library\ErrorMsg("Fehler beim Löschen des Standorts.", $e); die; } } }