简体   繁体   中英

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.

After a long search for solutions, I found this solution to use an ODBC driver. 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

I really tried all that I know and couldn't resolve this.

My EC2 configuration is:

yum install unixODBC unixODBC-devel freetds freetds-devel

And my odbc/freetds conf files are:

/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

[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

[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. 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.

Anyone can help me?

OBS: PHP RUNNING VERSION - PHP 5.6.10

A few things to consider:

  • What version of FreeTDS are you running?
  • What version of SQL Server are you running?

You need this to properly pick the correct TDS version. 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?

Here's a handy chart of what features are supported by which TDS version in FreeTDS:

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

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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