Skip to content

Commit

Permalink
Initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi committed Feb 9, 2012
1 parent 86d3c7f commit 1af6b32
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions SeparateDomainFromPresentation.php
@@ -0,0 +1,19 @@
<?php
$dsn = 'mysql:host=localhost;dbname=practical_php_refactoring';
$username = 'root';
$password = '';
$dbh = new PDO($dsn, $username, $password);
$stmt = $dbh->prepare("SELECT * FROM posts WHERE id_thread = :id_thread AND date >= :date ORDER BY date");
$stmt->bindValue(':id_thread', (int) $_GET['id_thread']);
if (!isset($_GET['last_visit'])) {
$_GET['last_visit'] = date('Y-m-d');
}
$stmt->bindValue(':date', $_GET['last_visit']);
$stmt->execute();
$post = $stmt->fetch();
?>
<div class="post">
<div class="author"><?php echo $post['author']; ?></div>
<div class="date"><?php echo $post['date']; ?></div>
<div class="text"><?php echo $post['text']; ?></div>
</div>

0 comments on commit 1af6b32

Please sign in to comment.