Advertisement
achshar

Untitled

May 8th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2.     class Article {
  3.             public function fetch_all() {
  4.                 global $pdo;
  5.  
  6.                 $query = $pdo->prepare("SELECT * FROM articles");
  7.                 $query->execute();
  8.  
  9.                 return $query->fetchAll();
  10.  
  11.             }
  12.  
  13.             public function fetch_data($article_id) {
  14.  
  15.             global $pdo;
  16.  
  17.             /*$query = $pdo->prepare("SELECT * FROM article WHERE article_id = ? ORDER BY id ASC");
  18.             $query->bindValue(1, $article_id);
  19.             $query->execute();
  20.  
  21.             return $query->fetch();*/
  22.  
  23.             $stmt = $pdo->prepare("SELECT * FROM article WHERE article_id = ?");
  24.             if($stmt->execute(array($article_id))) return $stmt->fetch();
  25.         }
  26.     }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement