Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\database;
- use PDO ;
- use PDOException ;
- class Connection{
- protected $db = "";
- private $username = "root";
- private $password = "";
- public function __construct(){
- try {
- $this->db = new PDO("mysql:host=localhost;dbname=resume", $this->username, $this->password);
- // set the PDO error mode to exception
- $this->db ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $this->db ->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
- echo "Connected successfully";
- }
- catch(PDOException $e){
- echo "Connection failed: " . $e->getMessage() . "<br>";
- die();
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement