Guest User

Untitled

a guest
Sep 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. require_once(Path::databaseClassPath() . 'Database.php');
  3.  
  4. class DatabaseHandler {
  5. private $mysqli;
  6.  
  7. public function __construct() {
  8. $this->connect();
  9. }
  10.  
  11. private function connect() {
  12. $this->mysqli = new mysqli(DB::host(), DB::username(), DB::password(), DB::name());
  13. if($this->mysqli->connect_errno) {
  14. die("Unable to connect to database: $mysqli->connect_errno - $mysqli->connect_error");
  15. }
  16. return $this->mysqli;
  17. }
  18.  
  19. public function prepare($query) {
  20. return $this->mysqli->prepare($query);
  21. }
  22.  
  23. public function stmt_init() {
  24. return $this->mysqli->stmt_init();
  25. }
  26.  
  27. public function close() {
  28. if(isset($mysqli))
  29. $this->mysqli->close();
  30. }
  31. }
  32. ?>
Add Comment
Please, Sign In to add comment