Update/Delete records in foxpro dbf using PHP

I need to update/delete foxpro dbf files which reside in a linux server by using PHP. dbase functions in PHP dont help. I heard of ODBTP but i not sure how to connect dbf since there are no drivers for linux. Any ideas?

The sample connection code for mssql looks like this
    $odbtpserver = 'odbtpsvr.somewhere.com';
    $mssqldriver = '{SQL Server}';
    $mssqlserver = 'MYMSSQLSERVER';
    $mssqluser   = 'sa';
    $mssqlpass   = '';
    $database    = 'OdbtpTest';

    $connstring  = "DRIVER=$mssqldriver;SERVER=$mssqlserver;UID=$mssqluser;PWD=$mssqlpass;DATABASE=$database;";

   $con = odbtp_connect( $odbtpserver, $connstring ) or die;

but for foxpro dbf  i dont know how.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Beverley PortlockCommented:
AFAIK, Foxpro uses dbase files (.DBF) so you need to enable the dbase.so extension in php.ini


and then you can use the dbase routines to read and write everything except memo fields.

See http://uk2.php.net/dbase for more information and examples
Here is the code on how to update and delete records.
//Update a record
// open in read-write mode
$db = dbase_open('/tmp/test.dbf', 2);

if ($db) {
  // gets the old row
  $row = dbase_get_record_with_names($db, 1);
  // remove the 'deleted' entry
  // Update the date field with the current timestamp
  $row['date'] = date('Ymd');
  // Replace the record
  dbase_replace_record($db, $row, 1);

//Delete a Record
// open in read-write mode
$db = dbase_open('/tmp/test.dbf', 2);

if ($db) {
  $record_numbers = dbase_numrecords($db);
  for ($i = 1; $i <= $record_numbers; $i++) {
      dbase_delete_record($db, $i);
  // expunge the database
//Packs the specified database by permanently deleting all records marked for deletion using dbase_delete_record().
scho1178Author Commented:
Due to a large database is in used, using dbase.so is not suitable for me. What i need is something like ODBC to query the tables.
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

If you use dbase commands, you will not be using the indexes of VFP and connectivity will be slow.

The option might be to use WINE and install windows MDAC on it. I am not too sure about it though.
scho1178Author Commented:
I am using Linux OS, hence installing MDAC might not be pratical for me. I feel that ODBTP is suitable for me but i just dunno how to connect to the dbf files in PHP.
I have never used ODBTP. It looks like you will need a windows box for it. Install MDAC and the ODBTP server on it. Either keep the DBF files on the windows server or if you want to keep them on the linux machine, you will need SAMBA and will have to keep them on a shared folder. I would advice on the former. Then you will have to use the ODBTP commands in php to connect to the dbf files.
scho1178Author Commented:
I am dealing with POS system, frontend is using .dbf database backend is using mysql database. Therefore i need to update 2 different database if there is any new updates, and there is only 1 Linux server.  All programs and databases are kept inside the Linux server. Having an additional windows pc/server will incurred more expenses. That is why i need some tools to access dbf in Linux.
Your solution might be installing WINE and then MDAC on top of it. give a visit to  http://www.winehq.org/ and see if you can find anything. If you do succeed, let me know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.