Guest User

Untitled

a guest
Sep 10th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. <?php
  2.  
  3. $host = '127.0.0.1';
  4. $db = 'test_db';
  5. $user = 'root';
  6. $pass = '';
  7. $charset = 'utf8mb4';
  8.  
  9. $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
  10. $opt = [
  11. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  12. PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  13. PDO::ATTR_EMULATE_PREPARES => false,
  14. ];
  15. try {
  16. $pdo = new PDO($dsn, $user, $pass, $opt);
  17. } catch (\PDOException $e) {
  18. throw new \PDOException($e->getMessage(), (int)$e->getCode());
  19. }
Add Comment
Please, Sign In to add comment