Advertisement
Guest User

Jory Geerts

a guest
May 27th, 2010
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2. header("content-type: text/plain");
  3.  
  4. class AnswerInfo
  5. {
  6.     public $question;
  7.     public $answer;
  8.     public $questiontypeid;
  9.     public $constructid;
  10.     public $construct;
  11.     public $comment;
  12. }
  13.  
  14. try {
  15.     $dbh = new PDO("mysql:dbname=test;host=localhost", "root", "");
  16. } catch (PDOException $e) {
  17.     echo 'Connection failed: ' . $e->getMessage();
  18. }
  19.  
  20. $stmt = $dbh->prepare("SELECT * FROM answer_info");
  21. $stmt->execute();
  22.  
  23. $before = microtime(true);
  24.  
  25. while( $obj = $stmt->fetchObject('AnswerInfo') )
  26. {
  27.     $after = microtime(true);
  28.     //var_dump($obj);
  29.     echo "Took " . ($after - $before) . " microseconds.".PHP_EOL;
  30.     $before = microtime(true);
  31. }
  32. $after = microtime(true);
  33. echo "Took " . ($after - $before) . " microseconds.".PHP_EOL;
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement