Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1.  
  2.              
  3. class DB_CONNECT {
  4.  
  5.     public $con = null;
  6.  
  7.     function __construct($host) {
  8.         $this->connect($host);
  9.     }
  10.  
  11.     function __destruct() {
  12.         $this->close();
  13.     }
  14.  
  15.     function connect($host) {
  16.    
  17.         $this->con = mysqli_connect($host, DB_USER, DB_PASSWORD, DB_DATABASE);
  18.         $this->con->set_charset("utf8");
  19.     }
  20.  
  21.     function close() {
  22.     if($this->con)
  23.            mysqli_close($this->con);
  24.     }
  25. }      
  26.  
  27.  
  28. $db = new DB_CONNECT('database-server-001');
  29.  
  30. $db->close();
  31.  
  32. $db = new DB_CONNECT("database-server-002");
  33.  
  34. $query = "SELECT * from his_track_recods";
  35.  
  36. $getHistResult = mysqli_query($db->con, $query);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement