A while back, i was researching for the same solution and hit many dead ends. i wanted a solution which worked with php though.
Some of them which i tried were
1. Xbase drivers: They worked well for simple DBFs, but then they do not support the newer data types like DateTime fields, so that option was ruled out.
2. VFP ODBC Driver : This works well if you are working on older VFP version since the development on this one has stopped and it does not support the newer autoincrement fields
and you keep getting strange errors like "Not a table" which drives you complete crazy.
"VFP ODBC Driver doesnt support Tables with autoincrement fields"
3. Commercial tools: There are many other commercial options which obviously wont work for me
4. Free Tools(DBF to CSV) which convert the DBF to a csv or similar, but then this will work if you are doing only select. You cant do any updates.
The last option which finally worked for me was:
Visual Foxpro OLE Driver.
You could install the OLE Driver from here.
Sample code looks like
$conn = new COM("ADODB.Connection");
$conn->Open('Provider=VFPOLEDB.1;Data Source="C:\\testDB.dbc";');
$query = "SELECT * FROM TABLE1 ";
$rs = $conn->Execute($query) or die("Error in query: $query. " . $conn->ErrorMsg());
while (!$rs->EOF) {
echo " Got COL1: " . $rs->Fields("COL1") . " :: COL2: " . $rs->Fields("COL2") . " id: " . $rs->Fields("ID") . "\n";
$rs->MoveNext();
}
$query = "UPDATE TABLE1 set COL1 = \"AA\", COL2 = \"Updated value\" ";
$conn->Execute($query);
I did not find any documentation for php but you could refer to MSDN ADO API
and use similar API especially if you want to do transaction based operations.
$conn->BeginTrans();
..
..
$conn->CommitTrans();
or
$conn->RollbackTrans();