Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Database{
- private $db;
- const sql_host = "localhost";
- const sql_base = "tetbase";
- const sql_user = "root";
- const sql_pass = "";
- public function __construct() {
- $mysqli = @new mysqli(self::sql_host, self::sql_user, self::sql_pass, self::sql_base);
- if(!$mysqli->connect_error) {
- $this->db = $mysqli;
- $this->db->query("SET NAMES 'utf8'");
- return $this->db;
- } else exit("<strong>[Error]</strong> MySQL connection failed");
- }
- public function query($sql) {
- return $this->db->query($sql);
- }
- public function assoc($result) {
- if(!empty($result)) {
- return $result->fetch_assoc();
- } else return false;
- }
- public function num_rows($query) {
- if(!empty($query)) {
- return $query->num_rows;
- } else return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement