GNT / Linux上的DataTables编辑器FreeTDS连接

时间:2015-05-29 23:27:54

标签: php sql-server linux datatable freetds

我开始使用Editor DataTables(http://editor.datatables.net/)。

我在Ubuntu Linux,PHP,Apache和Mysql上制作了一个Web Projecto。 一切正常,但现在,我需要连接到Windows Server上的SQL Server,但我无法连接,因为我没有安装sqldrv,因为它只适用于Windows。

实际上我已经安装了FreeTDS,并做了很多测试:

freetds.conf:

典型的Microsoft服务器

 [mssql]
   host = IP_SERVER
   port = 1433
   tds version = 4.2

ODBC.INI:

 Description = FreeTDS
 Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
 Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
 Database = plan_vuelo
 ServerName = mssql
 TDS_Version = 4.2

ODBCINST.INI:

[FreTDS]

 Description = FreeTDS
  Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
  client charset = utf-8

命令输出= tsql -C:

Compile-time settings (established with the "configure" script)
                            Version: freetds v0.91
             freetds.conf directory: /etc/freetds
     MS db-lib source compatibility: no
        Sybase binary compatibility: yes
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 4.2
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: yes

当我运行tsql时,连接成功:

$ tsql -S mssql -U sa -P Radec866
locale is "es_MX.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> select top 1 * from [plan_vuelo].[dbo].pv1_roles;
2> go
idRoles nombre  email   vendedor    responsable torre_control   admin   idUsuario   idSucursal
1   Vendedor Matriz micke_hp_2.0@hotmail.com    1   0   0   0   1   1
(1 row affected)
1> 

当我运行isql时:

$ isql -v mssql sa Radec866
SQL> select TOP 1 nombre, email from [plan_vuelo].[dbo].pv1_roles;
+-------------------------+--------------------+
| nombre                  | email                                                     
| Vendedor Matriz         | micke_hp_2.0@hotmail.com 
SQLRowCount returns 1
1 rows fetched

我的所有测试连接都是成功的,但我不知道如何编辑 /php/lib/Database/Driver/Sqlserver/Query.php

try 
  {
    $pdo = new PDO(
    `"sqlsrv:Server={$host}{$port};Database={$db}".self::dsnPostfix( $dsn)`,
    $user,
    $pass,
    array(
      PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
    ));
  } 
catch (\PDOException $e) 
  {
    // If we can't establish a DB connection then we return a DataTables
    // error.
    echo json_encode( array( 
      "sError" => "An error occurred while connecting to the database ".
      "'{$db}'. The error reported by the server was: ".$e->getMessage()
    ));
    exit(0);
   }

这是我的 Config.php 文件:

$sql_details = array(
    "type" => "Sqlserver",
    "user" => "sa",
    "pass" => "Radec866",
    "host" => "IP_SERVER",
    "port" => "",
    "db"   => "plan_vuelo",
    "dsn"  => "mmsql"
);

我该如何解决这个问题? 提前谢谢!

0 个答案:

没有答案