How to call the asscess database and COM program through ADO in PHP

Source: Internet
Author: User

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 ");
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.