Reply to Mysql Backup Connection in PHP

Your name:

Reply:


Posted by Locu on 04/12/06 19:26

I notice with PHP if a connection cannot be established to a mysql
server with mysql_connect() PHP will timeout and never try the backup
server. In this example:

$db = mysql_connect('db1.local.net', 'username', 'password');
if (!$db) {
$db = mysql_connect('db2.local.net', 'username', 'password');
}

This works great and connects to the 2nd database if the 1st one
rejects the connection completely; however, if the 1st db is under high
load and doesn't respond for 10+ seconds it never jumps to the 2nd one.
Curious if there's a better way to accomplish this. If the 1st db
doesn't respond in 1 second max I'd like to hop to the 2nd one.

Does the newer mysqli_connect handle this better, anyone know?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация