Advertisement
Guest User

PDO

a guest
Jul 21st, 2014
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  2. <?php
  3.     include('includes/FluentPDO/FluentPDO.php');
  4.     $pdo = new PDO("mysql:host=localhost;dbname=kncms;charset=utf8", "root", "",array(
  5.         PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
  6.     ));
  7.  
  8. $fpdo = new FluentPDO($pdo);
  9. $query = $fpdo->from('comments')->select(array('author', 'email', 'comment', 'comment_date'))->where('page_id', 3);
  10. foreach ($query as $row) {
  11.     $time = date("d/m/Y",strtotime($row['comment_date']));
  12.     $c = htmlentities($row['comment'], ENT_COMPAT, 'UTF-8');
  13.     echo "{$row['author']} {$row['email']} {$c} {$time} <br />";
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement