Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class connect
- {
- protected $username;
- protected $password;
- protected $dbname;
- protected $host;
- public $pdoo;
- function __construct()
- {
- $this->username = 'root';
- $this->password = '';
- $this->dbname = 'blog';
- $this->host = 'localhost';
- $this->connectToDb($this->username, $this->password, $this->host, $this->dbname);
- }
- protected function connectToDb($username, $password , $host, $dbname){
- try {
- $pdo = new PDO('mysql:host=' .$host .';dbname=' .$dbname, $username, $password);
- $pdo->setAttribute(PDO::ATTR_ERRMODE , PDO::ERRMODE_EXCEPTION);
- $this->pdoo = $pdo;
- } catch (PDOException $e) {
- echo $e->getMessage();
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement