| 1079 | * Check that the connection to the database is still up. If not, try to reconnect. |
| 1080 | * |
| 1081 | * @since 3.5.0 |
| 1082 | */ |
| 1083 | function check_connection() { |
| 1084 | $tries = 1; |
| 1085 | while ( ! mysql_ping( $this->dbh ) ) { |
| 1086 | if ( WP_DEBUG ) { |
| 1087 | $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true ); |
| 1088 | } else { |
| 1089 | $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true ); |
| 1090 | } |
| 1091 | |
| 1092 | if ( $this->dbh ) { |
| 1093 | $this->set_charset( $this->dbh ); |
| 1094 | $this->select( $this->dbname, $this->dbh ); |
| 1095 | |
| 1096 | return true; |
| 1097 | } |
| 1098 | |
| 1099 | $tries++; |
| 1100 | |
| 1101 | if ( $tries >= $this->reconnect_retries ) { |
| 1102 | $this->bail( sprintf( __( " |
| 1103 | <h1>Error reconnecting to the database</h1> |
| 1104 | <p>This means that we lost our connection to the database server at <code>%s</code>, your host's database server may be down.</p> |
| 1105 | <ul> |
| 1106 | <li>Are you sure that the database server is running?</li> |
| 1107 | <li>Are you sure that the database server is not under particularly heavy load?</li> |
| 1108 | </ul> |
| 1109 | <p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p> |
| 1110 | " ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' ); |
| 1111 | |
| 1112 | return false; |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | return true; |
| 1117 | } |
| 1118 | |
| 1119 | |
| 1120 | /** |