Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB
- {
- private $instance;
- function __construct() {
- $this->instance = new MySQLi("localhost","root","password","database");
- if($this->instance->connect_errno) {
- die("MySQL Error: " . $this->instance->connect_error . "<br />");
- }
- }
- public function Query($q) {
- return $this->instance->query($q);
- }
- public function TableExists($table) {
- $res = $this->Query("SHOW TABLES LIKE '$table'");
- return $res->num_rows > 0;
- }
- public function LastError() {
- return $this->instance->error;
- }
- public function Escape($v) {
- return $this->instance->real_escape_string($v);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement