I use FreeTDS
on Debian
to connect a php
-driven website to a MS-SQL Server 2005
Database.
The explanation I can give to the config files:
/etc/odbc.ini
Holds the instance that is referred to within the handler (e.g. php
) that connects to the database (see example below). The configuration defines the server it needs to connect to.
[freetds_odbc_connection]
Driver = FreeTDS
Description = test
Database = MyCompanyDb
Server = frodo
Readonly = Yes
Port = 1433
Trace = No
–
/etc/odbcinst.ini
Holds the configuration for the Driver
section in odbc.ini
.
[FreeTDS]
Description = TDS connection
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
UsageCount = 1
FileUsage = 1
Trace = Yes
TraceFile = /tmp/odbcinst_tr
–
show-companies.php
Example php
code to demonstrate how I set up and use the connection.
$host="freetds_odbc_connection";
$user="freetds";
$password="secretpassword";
$conn_id = odbc_connect($host, $user ,$password) or die (odbc_errormsg());
$sql_companies = "SELECT * from AMGR_Client_Tbl WHERE Record_Type="1"";
$query_companies = odbc_exec($conn_id, $sql_companies);
while (odbc_fetch_row($query_companies))
{
$client_id = odbc_result($query_companies, 6);
$company_name = odbc_result($query_companies, 9);
}
etc.. etc..
I’m sure there’s many other variables that can be set and used but this is the simplest explanation I can give of the files you asked about.