Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Mysql database class - only one connection alowed
- */
- class Database {
- private $_connection;
- private static $_instance; //The single instance
- private $_host = "46.101.140.93:3306";
- private $_username = "uber";
- private $_password = "pass";
- private $_database = "db_signature";
- /*
- Get an instance of the Database
- @return Instance
- */
- public static function getInstance() {
- return new self();
- }
- private function __construct() {
- error_reporting(E_ALL & ~E_WARNING);
- $this->_connection = new mysqli($this->_host, $this->_username,
- $this->_password, $this->_database);
- }
- private function __clone() { }
- public function getConnection() {
- if ($this->__isErrors()) {
- return null;
- }
- else {
- return $this->_connection;
- }
- }
- private function __isErrors() {
- if(mysqli_connect_error()) {
- return true;
- }
- else {
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement