Very good example and perfect.
There is also a 'database extraction layer' you can use which provides a very simple 'API' for use to connect to a large number of databases. This is for COM use utilizing both ODBC and OLEdb. This way, in the future, if you switch to Oracle, Sybase, MySQL, etc. it takes only 1-2 lines of change:
Here is a good place to download an ADODB library for you to use with your PHP applications:
//for windows
//for unix
This class library currently supports MySQL, PostgreSQL, Interbase, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase and generic ODBC. The Sybase and PostgreSQL drivers are community contributions.
<?
$dbc = new COM("ADODB.Connection"

;
$dbc->Provider = "MSDASQL";
$dbc->Open("nwind"

;
$rs = $dbc->Execute("select * from products"

;
$i = 0;
$fld0 = $rs->Fields(0);
$fld1 = $rs->Fields(1);
$fld2 = $rs->Fields(2);
while (!$rs->EOF) {
$i += 1;
print "$fld0->value $fld1->value $fld2->value<BR>";
$rs->MoveNext(); /*updates fld0, fld1, fld2 !*/
}
$rs->Close();
?>
Chad. ICQ: 54380631