Advertisement
Guest User

Untitled

a guest
Sep 30th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $con = getCon();
  2. $result = mysqli_query($con, "SELECT * FROM sometable WHERE deleted=0");
  3.  
  4. class Database{
  5. private static $db;
  6. private $connection;
  7.  
  8. private function __construct(){
  9. $servername = "localhost";
  10. $username = "...";
  11. $password = "...";
  12. $dbname = "...";
  13.  
  14. $this->connection = new mysqli($servername, $username, $password, $dbname);
  15. }
  16.  
  17. function __destruct() {
  18. $this->connection->close();
  19. }
  20.  
  21. public static function getConnection(){
  22. if(self::$db == null){
  23. self::$db=new Database();
  24. }
  25.  
  26. return self::$db->connection;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement