Home > Backend Development > PHP Tutorial > PHP Tips--Using ADODB through COM_PHP Tutorial

PHP Tips--Using ADODB through COM_PHP Tutorial

WBOY
Release: 2016-07-13 17:19:27
Original
721 people have browsed it


To implement the following functionality, please ensure that 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 randomly.

2. Implementation code

// This is the newly created database
$db = d:wwwrootdb.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);
?>




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

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532680.htmlTechArticleTo achieve the following functions, please ensure that the com.allow_dcom option in php.ini is set to true. 1. Preparation Create a new ACCESS database and name it db.mdb, and then in this database...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template