1
votes

I have a software using Visual Foxpro, so it's using dbf+cdx+fpt files to store all the data.

One of my projects was to collect all possible data from the software and show it on the web using PHP+HTML+CSS+Bootstrap.

I've been lucky doing this and the project looks amazing so far. But now I'm having a problem, and I wonder if you can help me.

All the data I need to show so far was on the .dbf file, but now I need to get data from .fpt file. The way I use to connect to on PHP doesn't allow me to show the data attached to fpt files, just data from dbf files.

I'm using the following structure so far to get this done:

  1. On a Windows Server, I have XAMPP installed and I created a ODBC Data Source of "Microsoft Visual FoxPro Driver" to the path of the software where all the dbf files are, and named that connection ConnectSofTo.
  2. To connect to dbf tables I am using the following code on a PHP page (as example):

    <?php 
    $conn = odbc_connect("ConnectSofTo", "", "") or die ("Error: could not connect to database"); 
    
    if (!$conn){exit("Connection Failed: " . $conn);} 
    
    $sql="
    SELECT movimentos.ORDEM, movimentos.DATA, movimentos.DOC, movimentos.COD_HASH
    FROM movcliente.dbf AS movimentos
    WHERE movimentos.DATA>={^2017-01-01} AND NOT movimentos.DOC='RCB' 
    ";
    
    $rs=odbc_exec($conn,$sql); 
    
    while(odbc_fetch_array($rs)){
    
    echo odbc_result($rs,"ORDEM")." | ".odbc_result($rs,"COD_HASH")."</br>";
    
    }?>
    

So, this code works fine, the problem is: the field COD_HASH it is a textfield with more than 70 random characters on it, and I need to show it on the web page.

This specific textfield is hosted on the fpt file, and I wonder if you know a way to show it on a php page.

Thank you for your attention in advance

1
See post stackoverflow.com/questions/1947348/…. I wrote VFP reading, but another answer had in PHP format a similar parsing to find the text portions...DRapp
The FPT file just holds the contents of memo-type fields in the DBF, because those fields have an arbitrary size up to 2GB. So just referencing the field in the DBF should be enough, you never access the FPT directly.Alan B

1 Answers

1
votes

I would extract all dbf (and fpt) info into a flat file (ASCII or UTF8) or XML file, with a simple VFP program, that could be a programmed process.

VFP can extract info to xml easily.... or doing a mini-program which include strtofile...

And PHP could read these files (XML...)

I've been using VFP for many years and trying to integrate and migrate to other systems, as Ruby on Rails and Oracle.. and this is my recomendation