Advertisement
skisr2000

database.php

Feb 1st, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. //require_once ("new_config.php");
  4.  
  5. class Database {
  6.  
  7.     public $connection;
  8.  
  9.     function __construct(){
  10.  
  11.     $this->open_db_connection();
  12.  
  13.         }
  14.  
  15.  
  16.     public function open_db_connection(){
  17.  
  18.     $this->connection = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
  19.  
  20.     if($this->connection->errno) {
  21.  
  22.         die("Database connection failed badly". " ".$this->connection->connect_error);
  23.         }
  24.  
  25.         }
  26.  
  27.  
  28.     public function query($sql){
  29.  
  30.         $result = $this->connection->query($sql);
  31.        
  32.         return $result;
  33.  
  34.         }
  35.  
  36.     private function confirm_query(){
  37.  
  38.         if(!$result){
  39.  
  40.         die("Query Failed". " ".$this->connection->connect_error);
  41.         }
  42.  
  43.         }
  44.  
  45.     public function escape_string($string){
  46.         $escaped_string = $this->connection->real_escape_string($string);
  47.         return $escaped_string;
  48.         }
  49.  
  50.     public function the_insert_id() {
  51.         return $this->connection->insert_id;
  52.  
  53.  
  54.     }
  55.  
  56. }
  57.  
  58.  
  59. $database = new Database();
  60.  
  61.  
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement