Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MySQL
- {
- public function __construct()
- {
- $this->Connect();
- }
- # MySQL Credentials..
- Private $Hostname = 'localhost';
- Private $Username = 'root';
- Private $Password = '';
- Private $Database = 'framework';
- function PingMySQLServer( $Connector )
- {
- // Ping the hostname provided in the Connect function.
- if( !mysql_ping( $Connector ) )
- {
- // Could not ping.
- return 0;
- }
- else
- {
- // Could ping. Possible restart of MySQL service just happened?
- return 1;
- }
- }
- private function Connect()
- {
- $Connector = @mysql_connect( $this->Hostname, $this->Username, $this->Password );
- // Check the connector if it didn't work above.. Does it work now?
- if( !$Connector )
- {
- // Maybe it doesn't, maybe it's a server problem. This will ping the hostname.
- if ( $this->PingMySQLServer( $Connector ) == 0 )
- {
- // Display custom error message.
- exit( "Sorry, we're under maintenance right now." );
- }
- }
- // Ignore any errors it trys to throw back..
- @mysql_select_db( $this->Database );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement