Source for file northwind-access.php
Documentation is available at northwind-access.php
<title>ODBTP PEAR DB Example: MS Access</title>
** This example shows how to connect to a MS Access database
** using the PEAR DB driver for ODBTP.
$dsn = 'odbtp(access)://127.0.0.1/c:\NorthWind.mdb?rowcache=yes';
$options['persistent'] = false;
$dbh = DB ::connect ( $dsn, $options );
if( PEAR ::isError ( $dbh ) ) {
echo "Error message: " . $dbh->getMessage () . "<br>\n";
echo "Detailed error description: " . $dbh->getDebugInfo () . "<br>\n";
$sql = "SELECT * FROM Customers AS C, Orders AS O "
. "WHERE O.CustomerId = C.CustomerId";
$res = $dbh->query ( $sql );
if( PEAR ::isError ( $res ) ) {
echo "Error message: " . $res->getMessage () . "<br>\n";
echo "Detailed error description: " . $res->getDebugInfo () . "<br>\n";
if( !($cols = $res->numCols ()) ) continue;
echo $res->numRows () . " rows<p>\n";
$colinfo = $res->tableInfo ();
if( PEAR ::isError ( $colinfo ) ) {
echo "Error message: " . $colinfo->getMessage () . "<br>\n";
echo "Detailed error description: " . $colinfo->getDebugInfo () . "<br>\n";
echo "<table cellpadding=2 cellspacing=0 border=1>\n";
echo "<td> <b>Table</b> </td>";
echo "<td> <b>Name</b> </td>";
echo "<td> <b>Type</b> </td>";
echo "<td> <b>Length</b> </td>";
echo "<td> <b>Flags</b> </td>";
for( $i = 0; $i < $cols; $i++ ) {
echo "<td> ". $colinfo[$i]['table'] . " </td>";
echo "<td> ". $colinfo[$i]['name'] . " </td>";
echo "<td> ". $colinfo[$i]['type'] . " </td>";
echo "<td> ". $colinfo[$i]['len'] . " </td>";
echo "<td> ". $colinfo[$i]['flags'] . " </td>";
echo "<table cellpadding=2 cellspacing=0 border=1>\n";
for( $col = 0; $col < $cols; $col++ ) {
echo "<td><nobr> " . $colinfo[$col]['name'] . " </nobr></td>";
while ( $row = $res->fetchRow () ) {
for( $col = 0; $col < $cols; $col++ ) {
if( is_null( $row[$col] ) ) $row[$col] = "NULL";
echo "<td valign=\"top\"><pre>";
while ( $res->nextResult () );
Documentation generated on Mon, 11 Mar 2019 15:32:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|