vavince,
here's the code i've used to get ms access and php working.
i found it to be slow (for me at least). It was on Win2k, php4.3.4 (approx ver) and access 2000.
jacksonpt,
yeah, initially i thought it seems like a good idea to have access work with php.. not suggested though (from my pov).
maybe someone has better luck.
here's the code:
define("DATA_DB", "d:\\path\\to\\db\\db1.mdb"); // should have double backslashes, the board isn't showing it though
//functions
function objConn(){
global $objConn;
//required
$objConn = new COM('ADODB.Connection');
// there are 3 ways to access the db.
// method 1
//$objConn->Provider = 'Microsoft.Jet.OLEDB.4.0';
//$objConn->Open(DATA_DB);
// method 2 and 3
$objConn->Open('DRIVER={Microsoft Access Driver (*.mdb)}; DBQ='.DATA_DB);
//$objConn->Open('Provider=Microsoft.Jet.OLEDB.4.0; Data Source='.DATA_DB);
}
function objClose(&$objConn, &$objRS){
if(is_resource($objRS)){
$objRS->Close();
$objRS->Release();
$objRS = null;
}
if(is_resource($objConn)){
$objConn->Close();
$objConn->Release();
$objConn = null;
}
//global $objConn;
if(isset($objConn)){
unset($objConn);
//echo 'Unset';
}
}
// usage
$objRS = $objConn->Execute("select * from Table1");
$id = $objRS->Fields('id');
$title = $objRS->Fields('title');
while (!$objRS->EOF) {
print "$id->value $title->value<BR>\n";
$objRS->MoveNext();
}
objClose($objConn, $objRS);
// alternatively
$objRS = $objConn->Execute("select * from Table1");
$id = $objRS->Fields('id');
$id = $id->value;
$title = $objRS->Fields('title');
$title = $title->value;
while (!$objRS->EOF) {
print "$id $title<BR>\n";
$objRS->MoveNext();
}
objClose($objConn, $objRS);
// alternative getting field values
$objRS->Fields(0);
someone might find it useful and 'hopefully' improve it.
-sijis