PHP and Merant ODBC Drivers in Progress 9

This is a quick start guide to configuring the supplied Merant ODBC drivers in PROGRESS 9 for use with PHP . The platform configuration is as follows:
  • Redhat Linux 7.2
  • Progress Version 9.1C installed in /usr/dlc
  • PHP 4.1.2

odbc.ini

Create an odbc.ini, traditionally resides in /etc
[ODBC Data Sources]

sportscon=Progress_SQL92_Driver

[sportscon]

Driver=/usr/dlc/odbc/lib/pgpro915.so
DatabaseName=sports
PortNumber=sportsrv
HostName=localhost
LogonID=sysprogress
Password=s
#APILevel=1
ConnectFunctions=YYN
#CPTimeout=60
#DriverODBCVer=03.60
#FileUsage=0
#SQLLevel=0
#UsageCount=1
#ArraySize=50
#DefaultIsolationLevel=REPEATABLE READ
#LogonID=ccall
#StaticCursorLongColBuffLen=4096

[ODBC]
InstallDir=/usr/dlc/odbc
Trace=0
TraceFile=odbctrace.out
TraceDll=/usr/dlc/odbc/lib/odbctrac.so
UseCursorLib=0

			
Remarked out items have had no effect on my testing so far, although they are included in suggested odbc.ini from Progress

Linux Configuration

Create an odbc.h file in the /usr/dlc/odbc/include directory

#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>
Modify the file
/etc/ld.so.conf
Add the entries
/usr/dlc/lib                     
/usr/dlc/odbc/lib                
then run
ldconfig
locate any other libodbc.so libraries apart from the one in /usr/dlc/odbc/lib and move them out of the library path.

Building a standalone PHP executable

Set the following environment variables
CUSTOM_ODBC_LIBS="-L/usr/dlc/odbc/lib -lodbc ";export CUSTOM_ODBC_LIBS
CFLAGS="-I/usr/dlc/odbc/include -L/usr/dlc/odbc/lib -lodbc";export CFLAGS
run configure in the PHP source directory

./configure --with-custom-odbc=/usr/dlc/odbc --without-mysql 
then run make. When complete there will be a php executable ready to copy into the cgi-bin directory of the web server.

Building an apache module

Set the following environment variables
CUSTOM_ODBC_LIBS="-L/usr/dlc/odbc/lib -lodbc ";export CUSTOM_ODBC_LIBS
CFLAGS="-I/usr/dlc/odbc/include -L/usr/dlc/odbc/lib -lodbc";export CFLAGS
Start with an apache source tree, run

./configure --activate-module=src/modules/php4/libphp4.a
Now go to the php source tree, run
./configure --with-custom-odbc=/usr/dlc/odbc --without-mysql 
--with-apache=/your_apache_dir/apache_1.33.23   
run make, if successful, run make install
Return to the apache source tree, Run ./configure --activate-module=src/modules/php4/libphp4.a again! (This is important as you will get a make error if you dont).
run make, if successful, run make install
The apache server is now installed. edit the httpd.conf file. Enter your server name, port etc. Make sure the mime type section includes the following information.
<IfModule mod_mime.c>                                                   
    TypesConfig /database/development/progress/apache/etc/mime.types      
                                                                          
    AddType application/x-httpd-php .php                                  
                                                                          
</IfModule>                                                               

Start the apache server.

Starting the sports database

Start a progress database server against the sports database

proserve sports -H localhost -S sportsrv -N TCP
Then create a user in the sports database with id "sysprogress", password "s".

Sample PHP code to access the sports database

<?php
// progresscode.php  - a simple php test
putenv("ODBCINI=/etc/odbc.ini");
//Line below important - stops a strange Merant 6060 error appearing on stdout
putenv("LD_LIBRARY_PATH=/usr/dlc/lib:/usr/dlc/odbc/lib");

$conn = odbc_connect("sportscon", "sysprogress", "s", SQL_CUR_USE_ODBC);
$result = odbc_do($conn, "SELECT custnum, name FROM pub.customer where custnum < 1000");
odbc_result_all($result);
?>


From a browser if you are running the cgi-bin php run the url

http://www.yourhost.com/cgi-bin/php/progresscode.php
or similar.

if you have the apache module run the url

http://www.yourhost.com/progresscode.php
or similar.
Hosted by www.Geocities.ws

1