Advertisement
Guest User

Untitled

a guest
Jul 20th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. $DB = new PDO($dsn);
  2.  
  3. //Why does this work
  4. $sql = "SELECT column FROM table WHERE id = 5";
  5. $true = $DB->query($sql);
  6. if($true) {
  7.     $results = $true->fetch(PDO::FETCH_ASSOC);
  8.     print_r($results); // shows results
  9. }
  10.  
  11. // But this doesn't work...
  12. $sql = "SELECT column FROM table WHERE id = ?";
  13. $ids[] = 5;
  14. $statement = self::$DB->prepare($sql);
  15. $true = $statement->execute($ids);
  16. if($true) {
  17.     $results = $statement->fetch(PDO::FETCH_ASSOC);
  18.     print_r($results); // shows empty
  19. }
  20.  
  21. // :(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement