Advertisement
Guest User

Untitled

a guest
May 7th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2. class MySQL
  3. {
  4. public function __construct()
  5. {
  6. $this->Connect();
  7. }
  8.  
  9. # MySQL Credentials..
  10. Private $Hostname = 'localhost';
  11. Private $Username = 'root';
  12. Private $Password = '';
  13. Private $Database = 'framework';
  14.  
  15. function PingMySQLServer( $Connector )
  16. {
  17. // Ping the hostname provided in the Connect function.
  18. if( !mysql_ping( $Connector ) )
  19. {
  20. // Could not ping.
  21. return 0;
  22. }
  23. else
  24. {
  25. // Could ping. Possible restart of MySQL service just happened?
  26. return 1;
  27. }
  28. }
  29. private function Connect()
  30. {
  31. $Connector = @mysql_connect( $this->Hostname, $this->Username, $this->Password );
  32.  
  33. // Check the connector if it didn't work above.. Does it work now?
  34. if( !$Connector )
  35. {
  36. // Maybe it doesn't, maybe it's a server problem. This will ping the hostname.
  37. if ( $this->PingMySQLServer( $Connector ) == 0 )
  38. {
  39. // Display custom error message.
  40. exit( "Sorry, we're under maintenance right now." );
  41. }
  42. }
  43.  
  44. // Ignore any errors it trys to throw back..
  45. @mysql_select_db( $this->Database );
  46. }
  47.  
  48. }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement