public function findAllComments()
 {
     $stmt = $this->dtb->prepare('SELECT * FROM comments');
     $stmt->execute();
     $data = array();
     $UM = new PdoUserManager();
     $PM = new PdoPostManager();
     while ($d = $stmt->fetch(PDO::FETCH_OBJ)) {
         $c = new Comment();
         $c->setId($d->id);
         $c->setBody($d->body);
         $c->setPost($PM->findPostById($d->postID));
         $c->setUser($UM->findUserById($d->userID));
         $c->setPublicationDate($d->publicationDate);
         $data[] = $c;
     }
     $stmt->closeCursor();
     return $data;
 }
예제 #2
0
 public function findAllCommentsForPostId($pid)
 {
     $stmt = $this->dtb->prepare('SELECT * FROM comments WHERE postID = :pid');
     $stmt->bindValue(':pid', $pid, PDO::PARAM_INT);
     $stmt->execute();
     $data = array();
     $um = new PdoUserManager();
     $pm = new PdoPostManager();
     while ($d = $stmt->fetch(PDO::FETCH_OBJ)) {
         $c = new Comment();
         $c->setId($d->id);
         $c->setBody($d->body);
         $c->setPost($pm->findPostById($d->postID));
         $c->setUser($um->findUserById($d->userID));
         $c->setPublicationDate($d->publicationDate);
         $data[] = $c;
     }
     $stmt->closeCursor();
     return $data;
 }
예제 #3
0
<?php

require_once __DIR__ . '/classes/manager/PdoPostManager.class.php';
require_once __DIR__ . '/classes/entities/User.class.php';
session_start();
if (!isset($_SESSION['user'])) {
    header('Location: ./login.php');
} else {
    $PM = new PdoPostManager();
    $post = $PM->findPostById($_GET['id']);
    ?>

<!doctype html>
<head>
	<title>Posts list</title>
	<meta charset="utf-8" />
</head>
<body>
	<?php 
    include './inc/menu.php';
    ?>
	<h1><?php 
    echo $post->getTitle();
    ?>
</h1>
	<em>by <?php 
    echo $post->getUser()->firstname . ' ' . $post->getUser()->lastname;
    ?>
 on <?php 
    echo date('d/m/Y H:i:s', $post->getPublicationDate());
    ?>