Home >Backend Development >PHP Tutorial >adodb.recordset PHP simple example of using ADODB through COM

adodb.recordset PHP simple example of using ADODB through COM

WBOY
WBOYOriginal
2016-07-29 08:35:541549browse

To implement the following functionality, make sure the com.allow_dcom option in php.ini is set to true.
1. Preparation
Create a new ACCESS database and name it db.mdb, then create a new table comtest in this database, containing two fields: id and title, and finally insert some data.
2. Implementation code
// It is the newly built database
$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 query and output data
$rs = $conn->Execute('SELECT * FROM comtest ');
?>




< ?php
while (!$rs->EOF) {
echo '';
echo '';
echo '';
$rs->MoveNext();
}
?>
IDTitle
'. $rs->Fields['id']->Value .'< ;/td>';
echo '
'. $rs->Fields['title']->Value .'

// Release resources
$rs->Close();
$conn->Close() ;
$rs = null;
$conn = null;
?>

The above introduces a simple example of adodb.recordset PHP using ADODB through COM, including the content of adodb.recordset. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn