Home >Backend Development >PHP Tutorial >Using ADO with PHP under Windows
This example creates a connection and uses ODBC to open the access database NorthWind (demonstration included when installing Access). After executing the SQL statement, the RecordSet object is returned. Example showing the first three fields:
$dbc = new COM("ADODB.Connection");
$dbc->PRovider = "MSDASQL";
$dbc->Open("nwind");
$rs = $dbc->Execute("select * from products");
$i = 0;
while (!$rs->EOF) {
$i += 1;
$fld0 = $rs->Fields(0);
$fld1 = $rs->Fields(1);
$fld2 = $rs->Fields(2);
print "$fld0->value $fld1->value $fld2->value
";
$rs->MoveNext();
}
$rs->Close();
?>
The above introduces the use of ADO in PHP under Windows, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.