PHP ODBC Accessing Foxpro Database

Here are the steps to prepare a development environment that utilize PHP to access Foxpro Database on Windows via Apache web server:

  1. Install XAMPP
  2. Install IDE of choice for PHP – for me, I use Netbeans 6.8 on Windows XP.  Download link:  https://netbeans.org/downloads/6.8/start.html?platform=windows&lang=en&option=all&version=6.8
  3. Install ODBC Visual Foxpro Driver
  4. Connecting to database as follows:
    $dsn = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=c:\\your database;Exclusive=NO;collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
            $this->cnx= odbc_connect($dsn,"","");

 

Note:  one can use foxpro functions in query.  For example, converting a string date to date can be written as:

$query = “SELECT ponum from table WHERE  ctod(TRIM(podate)) between {{$start_date}} and {{$end_date}}
. order by podate”;

link to foxpro functions:  https://msdn.microsoft.com/en-us/library/f2x2b62b(v=vs.80).aspx