コード例 #1
0
ファイル: PdoPostManager.class.php プロジェクト: XenoX/2web
 public function findPostById($id)
 {
     $um = new PdoUserManager();
     $stmt = self::$dtb->query('SELECT * FROM posts WHERE id = ' . intval($id));
     $data = $stmt->fetch(PDO::FETCH_OBJ);
     $data = new Post($data->id, $data->title, $data->body, $data->publicationDate, $um->findUserById($data->userID));
     $stmt->closeCursor();
     return $data;
 }
コード例 #2
0
 public function findPostById($id)
 {
     $stmt = $this->dtb->prepare('SELECT * FROM posts WHERE id = :id');
     $stmt->bindValue(':id', $id, PDO::PARAM_INT);
     $stmt->execute();
     $UM = new PdoUserManager();
     $CM = new PdoCommentManager();
     $d = $stmt->fetch(PDO::FETCH_OBJ);
     $data = new Post($d->id, $d->title, $d->body, $d->publicationDate, $UM->findUserById($d->userID), $CM->findAllCommentsForPostId($d->id));
     $stmt->closeCursor();
     return $data;
 }
コード例 #3
0
 public function findCommentById($id)
 {
     $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();
     $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;
 }
コード例 #4
0
ファイル: PdoUserManager.class.php プロジェクト: XenoX/2web
 public function __construct()
 {
     if (is_null(self::$dtb)) {
         self::$dtb = new PDO(DB_DSN, DB_USER, DB_PASSWD);
     }
 }
コード例 #5
0
ファイル: login.php プロジェクト: Rothen68/SUPINFO-courses
<?php

require __DIR__ . '/classes/manager/PdoUserManager.class.php';
session_start();
if (isset($_POST['login']) && isset($_POST['password'])) {
    $UM = new PdoUserManager();
    $user = $UM->authenticate($_POST['login'], $_POST['password']);
    if ($user !== false) {
        $_SESSION['user'] = $user;
        header('Location: ./postList.php');
    }
}
?>

<!doctype html>
<head>
	<title>Login</title>
</head>
<body>
	<h1>Login Page</h1>
	<form action="#" method="post">
		<label for="login">Login:</label>
		<input type="text" id="login" name="login" value="" />
		<br />
		<label for="password">Password:</label>
		<input type="password" id="password" name="password" value="" />
		<br />
		<br />
		<input type="submit" value="Se connecter" />
	</form>
</body>