How to call the Access database and COM program through ADO in PHP Tutorial-PHP Tutorial

Source: Internet
Author: User
In PHP, how does one call the Access database and COM program through ADO. 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 only PHP4 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 32-bit Microsoft
Windows.
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
";
$ 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 )";
$ Word-> visible = 1;
$ Word-> Documents-> Add ();
$ Word-> Selection-> Typetext ("This is a test ");
?>

Bytes. 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 operations can only be performed...

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.