PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; try { $pdo = new PDO($dsn, DB_USER, DB_PASS, $options); } catch (\PDOException $e) { // For development, it's okay to see the error. // In production, log this and show a generic error message. throw new \PDOException($e->getMessage(), (int)$e->getCode()); } } return $pdo; } ?>