Guest User

Untitled

a guest
Nov 30th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2.     class Connection {
  3.         public $host;
  4.         public $dbname;
  5.         public $user;
  6.         public $pass;
  7.  
  8.         public function setHost($host) {
  9.             $this->host = $host;
  10.         }
  11.         public function getHost(){
  12.             return $this->host;
  13.         }
  14.         public function setDbname($host) {
  15.             $this->dbname = $dbname;
  16.         }
  17.  
  18.         public function setUser($user) {
  19.             $this->user = $user;
  20.         }
  21.         public function getUser(){
  22.             return $this->user;
  23.         }
  24.         public function setPass($pass) {
  25.             $this->pass = $pass;
  26.         }
  27.     }
  28.  
  29.     $host = new Connection();
  30.     $host->setHost('localhost');
  31.    
  32.     $dbname = new Connection();
  33.     $dbname->setDbname('almgutec_zeus');
  34.    
  35.     $user = new Connection();
  36.     $user->setUser('almgutec_zeus');
  37.    
  38.     $pass = new Connection();
  39.     $pass->setPass('Vp2iXaO7');
  40.    
  41.     try {
  42.         $conn = new PDO('mysql:host='.$host->getHost.';dbname=almgutec_zeus', $host->getUser, $this->pass);
  43.         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  44.     }
  45.    
  46.     catch(PDOException $e) {
  47.         echo 'ERROR: ' . $e->getMessage();
  48.     }
  49. ?>
Add Comment
Please, Sign In to add comment