Guest User

Untitled

a guest
Jan 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2. class Database {
  3. public $_connection;
  4. //Store the single instance.
  5. private static $_instance;
  6.  
  7.  
  8. public static function getInstance(){
  9. if (!self::$_instance) {
  10. self::$_instance = new self();
  11. }
  12. return self::$_instance;
  13. }
  14. }
  15.  
  16. public function __construct() {
  17. $this-> _connection = new mysqli('localhost' , 'root' , '' , 'rtr');
  18. if(mysqli_connect_error()) {
  19. trigger_error('Failure to connect to the database' . mysqli_connect_error(), E_USER_ERROR);
  20. }
  21. }
  22.  
  23. private function __clone() {}
  24. public function getConnection() {
  25. return this->_connection;
  26. }
  27.  
  28. protected function Connecting() {
  29. $db = Database::getInstance();
  30. $mysqli = $db->getConnection();
  31. $sql_query = 'SELECT * FROM rtrcards';
  32. $result = $mysqli->query($sql_query);
  33. }
  34. }
  35.  
  36.  
  37.  
  38. ?>
Add Comment
Please, Sign In to add comment