Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB
- {
- /* VARIABLES */
- private $mysqli;
- private $result;
- /* PUBLIC FUNCTIONS*/
- public function __construct()
- {
- $DB_HOST = $GLOBALS['DB_HOST'];
- $DB_USER = $GLOBALS['DB_USER'];
- $DB_PASSWORD = $GLOBALS['DB_PASSWORD'];
- $DB_DATABASE = $GLOBALS['DB_DATABASE'];
- $this->mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_DATABASE);
- $this->mysqli->set_charset("utf8");
- }
- public function select($select)
- {
- $result = $this->mysqli->query("$select");
- if (!$result) {
- print("DATABASE ERROR!!! $this->mysqli->error");
- return;
- }
- $row = mysqli_fetch_assoc($result);
- return $row;
- }
- public function array_select($select)
- {
- $result = $this->mysqli->query("$select");
- $answer = array();
- while ($row = mysqli_fetch_assoc($result)) {
- $answer[] = $row;
- }
- if (!$answer)
- {
- print("DATABASE ERROR!!! $this->mysqli->error");
- return;
- }
- return $answer;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement