
# Created: # - UserModel + UserController # - MediaModel + MediaController # Removed: # - TaskModel + TaskController # - ProjectModel + ProjectController
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
namespace ppb\Model;
|
|
use ppb\Library\Msg;
|
|
|
|
class ProjectModel extends Database
|
|
{
|
|
public function readProject()
|
|
{
|
|
$pdo = $this->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);
|
|
}
|
|
}
|
|
} |