By John Lim.
Znsoft (http://www.phpease.com znsoftm@21cn.com)
PhP4 already supports Microsoft's COM technology. However, the com section is rarely mentioned in this document.
Here are some examples I have tried. I hope these will give you some ideas. Note that these can only run on a 32-bit Microsoft Windows platform.
Use PHP to activate ado
ADO is Microsoft's database object technology. Ado contains the objects that connect to the database, the record set objects that return data from the query statement, and the field objects that represent data elements.
Many databases do not directly support ADO. Instead, many databases support two levels of Microsoft database technology: ODBC and oledb. Many databases support ODBC, but oledb has a reputation for being faster than ODBC.
ADO is the API for packaging ODBC and oledb.
In this example, open a new ADO connection object, open a traditional access database for ODBC, and then execute the SQL query, a record set object will be returned. Then we will display the first three fields of the record set.
<?
$ 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 ();
?>
Use PHP to call Microsoft Word
This is another example:
<?
$ Word = new COM ("word. application") or die ("cannot start Microsoft Word ");
Print "loaded word version ($ word-> Version) \ n ";
$ Word-> visible = 1;
$ Word-> documents-> Add ();
$ Word-> selection-> typetext ("this is a test ");
?>