Advertisement
vencinachev

DBConnection

Dec 17th, 2020
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2. $host = '127.0.0.1';
  3. $db   = 'autopark';
  4. $user = 'root';
  5. $pass = '';
  6. $charset = 'utf8mb4';
  7.  
  8. $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
  9. $options = [
  10.     PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
  11.     PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  12.     PDO::ATTR_EMULATE_PREPARES   => false,
  13. ];
  14. try {
  15.      $pdo = new PDO($dsn, $user, $pass, $options);
  16.     // echo "Success!";
  17. } catch (\PDOException $e) {
  18.     die("MySQL problem");
  19. }
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement