This information is specific to Red Hat Enterprise Linux 5 (RHEL) using RPM packages, though you or your system administrator could compile the necessary tools instead.
The idea is to take an existing Linux system with Apache and PHP already installed, and change it to allow database access using ODBC. This requires:
For RHEL, this is relatively easy once you realize that the packages are already built for you.
yum install unixODBC yum install unixODBC-devel yum install unixODBC-kde
./configure --with-tdsver=8.0 --with-unixODBC=/usr/include make make install
The host will be different, and the choice of names in the square brackets is arbitrary, but becomes known as the ServerName.
[iaidb] host = iai-db.insttech.washington.edu port = 1433 tds version = 8.0
ODBCConfig
[ODBC Data Sources] [iaidb] Description = FreeTDS Driver = FreeTDS Servername = iaidb Database = UID = PWD = Port = 1433
[FreeTDS] Description = ODBC for SQL Server Driver = /usr/local/lib/libtdsodbc.so Setup = /usr/lib/libtdsS.so FileUsage = 1
yum install php-odbc service httpd restart
<?php $db = odbc_connect("iaidb", "css_test", "password") or die ("couldn't connect"); $result = odbc_exec($db, "select * from tablename "); while(odbc_fetch_row($result)) { print(odbc_result($result, "columnname1") . "<br>\n"); } odbc_free_result($result); odbc_close($db); ?>
http://cssgate.insttech.washington.edu/~css_test/test_db.php