简体   繁体   English

AWS EC2 linux + PHP + ODBC +远程MS SQL Server

[英]AWS EC2 linux + PHP + ODBC + Remote MS SQL Server

I'm developing a web application with an AWS EC2 server (using php) to access a MS SQL Server database. 我正在使用AWS EC2服务器(使用php)开发Web应用程序以访问MS SQL Server数据库。

After a long search for solutions, I found this solution to use an ODBC driver. 长期寻找解决方案后,我发现此解决方案可以使用ODBC驱动程序。 Fine, the development went well and I have no problems to connect to database or persist data. 很好,开发进行得很顺利,我没有问题可以连接到数据库或保留数据。

But when I deployed my application, any action returns this error: 但是,当我部署应用程序时,任何操作都会返回此错误:

ERRO: IM001: [unixODBC][Driver Manager]Driver does not support this function ERRO:IM001:[unixODBC] [驱动程序管理器]驱动程序不支持此功能

I really tried all that I know and couldn't resolve this. 我真的尝试了所有我知道的并且无法解决的问题。

My EC2 configuration is: 我的EC2配置是:

yum install unixODBC unixODBC-devel freetds freetds-devel yum安装unixODBC unixODBC-devel freetds freetds-devel

And my odbc/freetds conf files are: 我的odbc / freetds conf文件是:

/etc/odbc.ini /etc/odbc.ini

[TDS_NAME]
      Description = decription
      Driver = TDS_NAME
      Database = MY_DB
      Servername = TDS_NAME
      UID = VIPS
      Port = 1433
      TDS_Version= 7.3

/etc/odbcinst.ini /etc/odbcinst.ini

[TDS_NAME]
      Description = TDS Connection
      Driver64 = /usr/lib64/libtdsodbc.so
      Setup64 = /usr/lib64/libtdsS.so
      FileUsage = 1
      UsageCount = 1
[ODBC]
      Trace = yes
      TraceFile /tmp/odbc.log

/etc/freetds.conf /etc/freetds.conf

[TDS_NAME]
      host = MY_HOST
      port = MY_PORT
      tds version = 7.3

I run my queries using odbc_execute() or odbc_exec() and the error happens when my consult has some parameter. 我使用odbc_execute()或odbc_exec()运行查询,并且当我的咨询具有某些参数时发生错误。 I'm pretty sure that the problem isn't my configuration files because I can connect successfully to the server and run a simple "SELECT * FROM table" and connect using isql running any query goes well. 我很确定问题不是我的配置文件,因为我可以成功连接到服务器并运行简单的“ SELECT * FROM table”,然后使用isql进行连接,运行任何查询都可以。

Anyone can help me? 有人可以帮助我吗?

OBS: PHP RUNNING VERSION - PHP 5.6.10 OBS:PHP运行版本-PHP 5.6.10

A few things to consider: 需要考虑的几件事:

  • What version of FreeTDS are you running? 您正在运行什么版本的FreeTDS?
  • What version of SQL Server are you running? 您正在运行哪个版本的SQL Server?

You need this to properly pick the correct TDS version. 您需要使用它来正确选择正确的TDS版本。 You're configured to use TDS 7.3, which would require FreeTDS 0.95 and SQL Server 2008. If you're just doing basic stuff, perhaps consider changing your TDS Version to 7.2 or 7.1? 您已配置为使用TDS 7.3,这将需要FreeTDS 0.95和SQL Server2008。如果您只是做基本的工作,也许考虑将TDS版本更改为7.2或7.1?

Here's a handy chart of what features are supported by which TDS version in FreeTDS: 这是FreeTDS中哪个TDS版本支持哪些功能的方便图表:

http://www.freetds.org/userguide/choosingtdsprotocol.htm http://www.freetds.org/userguide/choosingtdsprotocol.htm

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM