init.php 348 B

12345678910111213
  1. <?php
  2. try {
  3. $dbh = new PDO('mysql:host=localhost;dbname=test2', "test2", "TeSt2");
  4. $result = $dbh->query('SELECT * from person');
  5. print_r(get_class($result) . "\n");
  6. foreach($result as $row) {
  7. print_r($row);
  8. }
  9. $dbh = null;
  10. } catch (PDOException $e) {
  11. print "Error!: " . $e->getMessage() . "<br/>";
  12. die();
  13. }