MSSQL FREETDS kurulum notları:
1 – sudo apt-get install -y unixodbc unixodbc-dev unixodbc-bin libodbc1 odbcinst1debian2 tdsodbc php7.0-odbc
2 – sudo apt-get install -y freetds-bin freetds-common freetds-dev libct4 libsybdb5
3 – sudo nano /etc/odbcinst.ini ve aşağıdakileri ekle;
[ODBC]
Trace = No
TraceFile = /tmp/odbc.log
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
UsageCount = 1
4 – sudo nano /etc/odbc.ini ve aşağıdakileri ekle;
[dbserverdsn]
Driver = FreeTDS
Server = 192.168.XXX.X51
Port = 1433
Database = <MC…POS>
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
UsageCount = 1
[Default]
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
5 – sudo nano /etc/freetds/freetds.conf açılır ve dosya içeriği aşağıdaki gibi yapılır;
_________________________________________________________________________________________________
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage “man freetds.conf”.
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
tds version = 4.2
port = 1433
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting ‘text size’ to a more reasonable limit
text size = 64512
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[dbserverdsn]
database = <MC…POS>
host = 192.168.XXX.x51
port = 1433
tds version = 7.0
client charset = UTF-8
_________________________________________________________________________________________________
kaydedilir ve çıkılır.
6 – PHP test sayfası :
<?php
ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);
$baglanti = odbc_connect(“dbserverdsn”,”sa”,”user_sifre”);
if ($baglanti) echo “<span style=’color:green’>Baglandi</span>”.”</br>”;
$sorgu = odbc_exec($baglanti,”SELECT e.firstname, e.lastname,e.posref FROM LOCATION_ACTIVITY_DB.dbo.XXXXXXX e”);
while( $row = odbc_fetch_array($sorgu) ){
echo $row[“firstname”].” “.$row[“lastname”].”<br>”;
}
?>
7 – Başka DB lere bağlanılacaksa /etc/odbc.ini dosyasına eklenip bağlantı yapılabilir. Örnek;
sudo nano /etc/odbc.ini
[xxx_pos]
Driver = FreeTDS
Server = 192.168.XXX.X51
Port = 1433
Database = <MC..POS>
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
UsageCount = 1
[yyy_pos]
Driver = FreeTDS
Server = 192.168.XXX.X51
Port = 1433
Database = <DB_ISMI>
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
UsageCount = 1
Not : Başka db ye bağlanırken o db yi sorguda belirtilmelidir.
Örnek :
$baglanti = odbc_connect(“xxx_pos”,”sa”,”user_sifre”);
veya
$baglanti = odbc_connect(“yyy_pos”,”sa”,”user_sifre”);
gibi…
8 – “service apache2 restart” komutuyla apache restart edilir ve işlem bitti…