Primero instalar el unixODBC
1 2 3 |
yum install unixODBC* yum install php-odbc* yum install freetds |
Probar la conexion
1 |
tsql -S SERVIDOR –U USUARIO |
Editar /etc/odbc.ini
1 2 3 4 5 6 7 8 |
[solsaludtds] Description = TDS Driver = TDS Server = 192.168.1.252 Database = solsalud UID = callcenter PWD = call.cn.sol.2007 port = 1433 |
Editar /etc/odbcinst.ini
1 2 3 4 5 |
[TDS] Description = v0.60 with Protocol v7.0 Driver = /usr/lib/libtdsodbc.so.0 Setup = /usr/lib/libtdsS.so.1 FileUsage = 1 |
Si el sistema esta a 64bits
1 2 3 4 5 |
[TDS] Description = v0.60 with Protocol v7.0 Driver = /usr/lib64/libtdsodbc.so.0 Setup = /usr/lib64/libtdsS.so.1 FileUsage = 1 |
Probar la conexion
1 |
isql -v solsalud USUARIO CLAVE |
Para probar el PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
#!/usr/bin/php -q <?php $sql="select * from ips"; $conn=odbc_connect('solsaludtds','sa','password'); if (!$conn) {exit("Connection Failed -: " . $conn);} $rs=odbc_exec($conn,$sql); if (!$rs) { echo "Error en SQL"; } $i=0; if (odbc_fetch_row($rs)) { $compname18=odbc_result($rs,18); $i=1; } if ($i==1) { echo "REGISTRO ENCONTRADO"; if($compname18=="1") { echo "CLAVE OK"; }else { echo "CLAVE ERRONEA"; } } else { echo "REGISTRO NO ENCONTRADO"; } odbc_close($conn); ?> |