Simple example of using ADODB through COM in PHP _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
A simple example of using ADODB through COM in PHP. To implement the following functions, make sure that the com. allow_dcom option in php. ini is set to true. 1. prepare to create an ACCESS database and name it db. mdb. to implement the following functions in the database, make sure that the com. allow_dcom option in php. ini is set to true.

I. preparations

Create an ACCESS database and name it db. mdb. Then, create a new table comtest in the database, which contains the id and title fields, and insert some data at will.

II. implementation code

// The database you just created
$ Db = 'd: \ wwwroot \ db. mdb ';

// Establish a connection and open
$ Conn = new COM ('adodb. connection') or die ('Can not start Active X Data objects ');
// $ Conn-> Open ("Provider = Microsoft. Jet. OLEDB.4.0; Data Source = $ db ");
$ Conn-> Open ("DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ = $ db ");

// Execute the query and output data
$ Rs = $ conn-> Execute ('select * FROM comtest ');
?>











While (! $ Rs-> EOF ){Echo' ';Echo' ';Echo' ';Echo' ';$ Rs-> MoveNext ();}?>
ID Title
'. $ Rs-> Fields ['id']-> Value .''. $ Rs-> Fields ['title']-> Value .'

// Release resources
$ Rs-> Close ();
$ Conn-> Close ();
$ Rs = null;
$ Conn = null;
?>

Bytes. 1. prepare to create an ACCESS database and name it db. mdb. Then, create a new ACCESS database...

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.