Sometime back in July or August Microsoft slipped out a driver for PHP 5 on windows. It uses the SQL Native Client which means that it also supports automatic transparent client redirect. Change this connection info array from:
$connectionInfo = array("Database"=>"AdventureWorks",
"UID"=>"sa",
"PWD"=>"foobar23$");
to
$connectionInfo = array("Database"=>"AdventureWorks",
"UID"=>"sa",
"PWD"=>"foobar23$",
"Failover_Partner"=>"mirror.sql.local");
and you've now got automatic failover capability. You need to be running a witness for this magic to happen. If you're running on a Linux box this capability is not available but you can always try something like:
http://www.evolt.org/failover-database-connection-with-php-mysql