linkDB(); $sql = "SELECT * FROM users"; try { $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } catch (\PDOException $e) { new Msg(true, null, $e); } $sth = $pdo->prepare($sql); $sth->execute(); $result = $sth->fetchAll(\PDO::FETCH_ASSOC); $sth->closeCursor(); $pdo = null; // fetch all return $result; } public function insertNewMediaType($data) { $pdo = $this->linkDB(); try { // it should add an new type and it is Files $sql = "INSERT INTO media_types (id, type) VALUES (:id, :type)"; $sth = $pdo->prepare($sql); $sth-> execute([ ':id' => $this->createUUID(), ':type' => $data['Files'] ]); $pdo = null; new Msg(false, "Medientyp erfolgreich eingefügt."); } catch (\PDOException $e) { new Msg(true, 'Fehler beim Einfügen des Medientyps', $e); } } }