在Windows版的PHP中使用ADO
發(fā)表時(shí)間:2024-05-18 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]這個(gè)例子建了一個(gè)連接,用ODBC打開(kāi)Access的數(shù)據(jù)庫(kù)NorthWind(安裝Access時(shí)帶的示范)。在執(zhí)行了SQL語(yǔ)句后,返回了RecordSet對(duì)象。例子顯示了前三個(gè)字段: <? dbc = new COM("ADODB.Connection"); dbc-...
這個(gè)例子建了一個(gè)連接,用ODBC打開(kāi)Access的數(shù)據(jù)庫(kù)NorthWind(安裝Access時(shí)帶的示范)。在執(zhí)行了SQL語(yǔ)句后,返回了RecordSet對(duì)象。例子顯示了前三個(gè)字段:
<?
$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<BR>";
$rs->MoveNext();
}
$rs->Close();
?>