finalisation de ma part :)

This commit is contained in:
2019-03-06 09:13:31 +01:00
parent 9df001d565
commit cc8ee929f8
13 changed files with 91 additions and 101 deletions

View File

@ -12,7 +12,7 @@ class Author {
private $password;
private $job;
private $job = "Aprenant";
private $role = "ROLE_USER";
@ -134,15 +134,16 @@ class Author {
}
public static function remove(Author $author) {
Functions::connect()->prepare("DELETE FROM author WHERE id=:id")->execute(array(":id" => $author->getId()));
Functions::connect()->prepare("DELETE FROM users WHERE id=:id")->execute(array(":id" => $author->getId()));
}
public static function update(Author $author) {
Functions::connect()->prepare("UPDATE author SET name=':name', password=':password', job=':job' WHERE id=:id")->execute(array(
Functions::connect()->prepare("UPDATE users SET username=:username, password=:password, job=:job, role=:role WHERE id=:id")->execute(array(
":username" => $author->getUsername(),
":password" => $author->getPassword(),
":job" => $author->getJob(),
":role" => $author->getRole(),
":id" => $author->getId()
));
}

View File

@ -286,7 +286,16 @@ class Post {
*
*/
public static function remove(Post $post) {
Functions::connect()->prepare("DELETE FROM posts WHERE id=:id")->execute(array(":id" => $post->getId()));
$id = $post->getId();
$prepared = Functions::connect()->prepare("DELETE FROM post_tag WHERE post_id=:id");
$prepared->bindValue(":id", $id, PDO::PARAM_INT);
$prepared->execute();
$prepared = Functions::connect()->prepare("DELETE FROM posts WHERE id=:id");
$prepared->bindValue(":id", $id, PDO::PARAM_INT);
$prepared->execute();
}