
# Created: # - UserModel + UserController # - MediaModel + MediaController # Removed: # - TaskModel + TaskController # - ProjectModel + ProjectController
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace ppb\Model;
|
|
|
|
use ppb\Library\Msg;
|
|
|
|
class TaskModel extends Database {
|
|
|
|
public function insertTask($data) {
|
|
$pdo = $this->linkDB();
|
|
|
|
try {
|
|
|
|
$sql = "INSERT INTO task (id, userId, projectId, title, expense, dueDate, priorityId, done )
|
|
VALUES (:id,:userId,:projectId, :title, :expense, :dueDate, :priorityId, :done)";
|
|
$sth = $pdo->prepare($sql);
|
|
$sth-> execute([
|
|
':id' => $this->createUUID(),
|
|
':userId' => '4f141df7-3c0a-11e8-b046-2c4d544f8fe0',
|
|
':projectId' => $data['projectId'],
|
|
':title' => $data['title'],
|
|
':expense' => str_replace("," , "." ,$data['expense']),
|
|
':dueDate' => date("Y-m-d", strtotime($data['dueDate'])),
|
|
':priorityId' => $data['priorityId'],
|
|
':done' => 0
|
|
]);
|
|
|
|
|
|
$pdo = null;
|
|
|
|
new Msg(false, "Task erfolgreich eingefügt.");
|
|
} catch (\PDOException $e) {
|
|
new Msg(true, 'Fehler beim Einfügen des Tasks', $e);
|
|
}
|
|
|
|
}
|
|
}
|