The main problem I have found with pconnect is the host does NOT know how to set up correctly but once it's set up right it works great. However I made this little for loop in my pconnect section of db.inc.php to handle the problem until the host finally found and fixed their problem.
My moded version with Pconnect adding a for loop to retry conections.
PHP Code:
for ( $i = 0; $i < 75; $i++ ) {
if ( !$this->link = @mysql_pconnect( $this->host . $this->port . $this->sock, $this->user, $this->passwd ) ) {
usleep(50000); #Not available on windows before PHP 5.0
}else{
BREAK;
}
}#[ END ] 1st for ( $i = 0; $i < DB_ATTEMPTS; $i++ )
To remove Pconnect use
PHP Code:
for ( $i = 0; $i < 75; $i++ ) {
if ( !$this->link = @mysql_connect( $this->host . $this->port . $this->sock, $this->user, $this->passwd ) ) {
usleep(50000); #Not available on windows before PHP 5.0
}else{
BREAK;
}
}#[ END ] 1st for ( $i = 0; $i < DB_ATTEMPTS; $i++ )
Note I left the for loop in, this is because there are others on the same server and when their scripts go wild and hog connections I don't want to display an error until I've made at least 75 attempts to connect with a 50millisecond delay between attempts.
Pconnector works great! There is no reason to remove it, if you are having problems more than likely it's not with Pconnect it's the way your host has it set up which is not correct.
Pconnect reuses already open connections which is good and reduces connection resources.
If you disable pconnecat as above then you will need to modify each page and add the mysql_close to the bottom of every page in Aedating
Bookmarks