程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> UsingCOMwithPHP(我就不翻譯了)

UsingCOMwithPHP(我就不翻譯了)

編輯:關於PHP編程

Using COM with PHP
     By John Lim.
PHP4 on Windows has been extended to support Microsoft's COM technology. However documentation on the COM functions is very sparse at the moment.
Here are some examples of stuff I have tried. Hope this gives you some ideas. Note that these only work when you are running PHP on a Windows Web server.
Active Data Objects (ADO) with PHP
ADO is Microsoft's database object technology. There are objects for connecting to databases, recordsets for data returned from queries, and field objects representing data elements.
Most databases do not support ADO directly. Instead most databases support 2 lower level Microsoft database technologies: ODBC and OLEDB. More databases support ODBC; but OLEDB has a reputation of being faster than ODBC.
ADO is then an API wrapper around ODBC and OLEDB.
This example opens a new ADO Connection object, opens the traditional NorthWind MS-Access database via ODBC. When we execute the SQL, a RecordSet object is returned. We then display the first 3 fields of the record-set.
<?
    $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 !*/
    }

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved