Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define("DEBUG", true);
- class db {
- private $db;
- private $instance;
- private $debug;
- private function __constructor($debug) {
- $this->debug = $debug;
- $this->db = new mysqli('123.45.56.67', 'username',
- 'password', 'tablename'); //Where 123.45.56.67' is the ip of the
- database
- }
- public static function instance($debug = DEBUG) {
- if(!self::$instance) {
- $className = __CLASS__;
- self::$instance = new $className($debug);
- }
- return self::$instance;
- }
- /**
- * Generic select function. <br>
- */
- public function select($query) {
- $result = $this->db->query($query);
- flush();
- return $result;
- }
- /**
- * Generic update function. <br>
- * If debug is true, it doesn't update. <br>
- */
- public function update($query) {
- if($this->debug) {
- print $query;
- return true;
- } else {
- $result = $this->db->query($query);
- flush();
- return $result;
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment