206 if ( $dbhost && !empty($dbport) && $dbport != 3306 ) |
206 if ( $dbhost && !empty($dbport) && $dbport != 3306 ) |
207 $dbhost = '127.0.0.1'; |
207 $dbhost = '127.0.0.1'; |
208 |
208 |
209 $host_line = ( preg_match('/^:/', $dbhost) ) ? $dbhost : "{$dbhost}:{$dbport}"; |
209 $host_line = ( preg_match('/^:/', $dbhost) ) ? $dbhost : "{$dbhost}:{$dbport}"; |
210 |
210 |
211 $this->_conn = @mysql_connect($host_line, $dbuser, $dbpasswd); |
211 // Try a peristent connection twice |
|
212 // http://us2.php.net/manual/en/function.mysql-pconnect.php#99380 |
|
213 $this->_conn = @mysql_pconnect($host_line, $dbuser, $dbpasswd); |
|
214 if ( !@mysql_query("SELECT 1;", $this->_conn) ) |
|
215 { |
|
216 $this->_conn = @mysql_pconnect($host_line, $dbuser, $dbpasswd); |
|
217 if ( !@mysql_query("SELECT 1;", $this->_conn) ) |
|
218 { |
|
219 // if that doesn't work, use a normal connection |
|
220 $this->_conn = @mysql_connect($host_line, $dbuser, $dbpasswd); |
|
221 trigger_error(E_USER_WARNING, "Forced to use nonpersistent mysql connection"); |
|
222 } |
|
223 } |
212 unset($dbuser); |
224 unset($dbuser); |
213 unset($dbpasswd); // Security |
225 unset($dbpasswd); // Security |
214 |
226 |
215 if ( !$this->_conn && !$manual_credentials ) |
227 if ( !$this->_conn && !$manual_credentials ) |
216 { |
228 { |