PHP skills - through the use of COM ADODB
To achieve the following features, please ensure that the com.allow_dcom php.ini option has been set to true.
First, preparation work
ACCESS a new database, and was named db.mdb, and then the database in a new table comtest, including id and two field title last casually insert some data.
Second, to achieve code
<? Php
/ / Database is built just
$ Db = 'd: \ \ wwwroot \ \ db.mdb';
/ / Connect, 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 a query and output data
$ Rs = $ conn-> Execute ( 'SELECT * FROM comtest');
–>
<table Border="1">
<tr> <th> ID </ th> <th> Title </ th>
</ Tr>
<? Php
While (! $ Rs-> EOF) (
Echo '<tr>';
Echo '<td>'. $ Rs-> Fields [ 'id'] -> Value. '</ Td>';
Echo '<td>'. $ Rs-> Fields [ 'title'] -> Value. '</ Td>';
Echo '</ tr>';
$ Rs-> MoveNext ();
)
–>
</ Table>
<? Php
/ / Release resources
$ Rs-> Close ();
$ Conn-> Close ();
$ Rs = null;
$ Conn = null;
–>








0 Comments to “PHP skills - through the use of COM ADODB”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.