Guest User

Untitled

a guest
May 29th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. var_dump(Pdo::getAvailableDrivers());
  4.  
  5. foreach (Pdo::getAvailableDrivers() as $driver => $d) {
  6. try {
  7. echo $dsn = $d . ':dbname=testdb;host=127.0.0.1';
  8. echo PHP_EOL;
  9.  
  10. $dbh = new PDO($dsn, 'dbuser', 'dbpass');
  11. } catch(PDOException $e) {
  12. echo 'Connection failed: ' . $e->getMessage();
  13. }
  14. }
  15.  
  16. try {
  17. echo PHP_EOL;
  18. echo $dsn = 'cirpo:dbname=testdb;host=127.0.0.1';
  19. $user = 'dbuser';
  20. $password = 'dbpass';
  21.  
  22. $dbh = new PDO($dsn, $user, $password);
  23. } catch(PDOException $e) {
  24. echo 'Connection failed: ' . $e->getMessage();
  25. }
Add Comment
Please, Sign In to add comment