Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. class Database{
  2.  
  3. // specify your own database credentials
  4. private $host = "localhost";
  5. private $db_name = "visiotne_biblioteka";
  6. private $username = "root";
  7. private $password = "";
  8. public $conn;
  9.  
  10. // get the database connection
  11. public function getConnection(){
  12.  
  13. $this->conn = null;
  14.  
  15. try{
  16. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  17. $this->conn->exec("set names utf8");
  18. }catch(PDOException $exception){
  19. echo "Connection error: " . $exception->getMessage();
  20. }
  21. return $this->conn;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement