daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest Dec 29th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class DB
  3. {
  4. /* VARIABLES */
  5.     private $mysqli;
  6.     private $result;  
  7. /* PUBLIC FUNCTIONS*/
  8.  
  9.     public function __construct()
  10.     {
  11.         $DB_HOST = $GLOBALS['DB_HOST'];
  12.         $DB_USER = $GLOBALS['DB_USER'];
  13.         $DB_PASSWORD = $GLOBALS['DB_PASSWORD'];
  14.         $DB_DATABASE = $GLOBALS['DB_DATABASE'];
  15.         $this->mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE);
  16.         $this->mysqli->set_charset("utf8");
  17.     }
  18.  
  19.     public function select($select)
  20.     {
  21.         $result = $this->mysqli->query("$select");
  22.         if (!$result) {
  23.             print("DATABASE ERROR!!! $this->mysqli->error");
  24.             return;
  25.         }
  26.         $row = mysqli_fetch_assoc($result);
  27.         return $row;
  28.     }
  29.    
  30.     public function array_select($select)
  31.     {
  32.         $result = $this->mysqli->query("$select");
  33.         $answer = array();
  34.         while ($row = mysqli_fetch_assoc($result)) {
  35.             $answer[] = $row;
  36.         }
  37.         if (!$answer)
  38.         {
  39.             print("DATABASE ERROR!!! $this->mysqli->error");
  40.             return;
  41.         }
  42.         return $answer;
  43.     }
  44.  
  45. }
  46. ?>
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