| 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 | sleep( 1 ); |
| 1116 | } |
| 1117 | |
| 1118 | return true; |
| 1119 | } |
| 1120 | |
| 1121 | |
| 1122 | /** |
| 1198 | * Internal function to perform the mysql_query call |
| 1199 | * |
| 1200 | * @since 3.5.0 |
| 1201 | * |
| 1202 | * @access private |
| 1203 | * @see wpdb::query() |
| 1204 | * |
| 1205 | * @param string $query The query to run |
| 1206 | */ |
| 1207 | private function _do_query( $query ) { |
| 1208 | if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) |
| 1209 | $this->timer_start(); |
| 1210 | |
| 1211 | $this->result = @mysql_query( $query, $this->dbh ); |
| 1212 | $this->num_queries++; |
| 1213 | |
| 1214 | if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) |
| 1215 | $this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() ); |
| 1216 | } |
| 1217 | |
| 1218 | /** |