How to call an Asscess database and COM programs in PHP through ADO

zhaozj2021-02-08  278

znsoft Translation of: John Lim.

PHP4 has supported Microsoft COM technology. However, there are few in the COM part in the document.

Here is a few examples I have tried. I hope these will give you some concepts. Note that these can only run under 32-bit Microsoft Windows platforms.

Use PHP to activate ADO

ADO is Microsoft's database object technology. The ADO includes an object to connect to the database, and returns the data of the record set object and the field object of the data element from the query statement.

Many databases do not directly support ADO. Many databases support low-level Microsoft database technologies: ODBC and OLEDB. Many databases support ODBC; but OLEDB has a faster reputation than ODBC.

ADO is a Packaging ODBC and OLEDB API.

This example opens a new ADO connection object, open a traditional Access database over ODBC, and then we execute the SQL query, will return a recordset object. Then we display the first three fields of the record set.

$ dbc = new com ("adoDb.connection");

$ dbc-> provider = "msdasql";

$ dbc-> open ("nwind");

$ r = $ dbc-> execute ("Select * from products");

$ I = 0;

While (! $ r-> eof) {

$ i = 1;

$ FLD0 = $ r-> Fields (0);

$ FLD1 = $ r-> Fields (1);

$ FLD2 = $ r-> Fields (2);

Print "$ fld0-> value $ fld1-> value $ fld2-> value
";

$ r-> movelnext ();

}

$ r-> close ();

?>

Call Microsoft Word with PHP

This is another example:

$ Word = New Com ("Word.Application" OR Die ("Cannot Start Microsoft Word";

Print "Loaded Word Version / N";

$ Word-> Visible = 1;

$ Word-> Documents-> Add ();

$ Word-> Selection-> Typetext ("this is a test");

?>

转载请注明原文地址:https://www.9cbs.com/read-1345.html

New Post(0)