Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database {
- public $_connection;
- //Store the single instance.
- private static $_instance;
- public static function getInstance(){
- if (!self::$_instance) {
- self::$_instance = new self();
- }
- return self::$_instance;
- }
- }
- public function __construct() {
- $this-> _connection = new mysqli('localhost' , 'root' , '' , 'rtr');
- if(mysqli_connect_error()) {
- trigger_error('Failure to connect to the database' . mysqli_connect_error(), E_USER_ERROR);
- }
- }
- private function __clone() {}
- public function getConnection() {
- return this->_connection;
- }
- protected function Connecting() {
- $db = Database::getInstance();
- $mysqli = $db->getConnection();
- $sql_query = 'SELECT * FROM rtrcards';
- $result = $mysqli->query($sql_query);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment