daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. namespace library\database;
  3.  
  4. use PDO;
  5. use PDOException;
  6.  
  7. class Database
  8. {
  9.     public $conn;
  10.  
  11.     function __construct()
  12.     {
  13.         $dbhost = "localhost";
  14.         $user = "username";
  15.         $pass = "password";
  16.         $dbname = "database";
  17.  
  18.         try
  19.         {
  20.             $this->conn = new PDO("mysql:host=$dbhost;port=3306;dbname=$dbname", $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
  21.             $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  22.         }
  23.         catch(PDOException $e)
  24.         {
  25.             echo $e->getMessage();
  26.         }
  27.     }
  28. }
  29.  
  30. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top