1

I am using Mac OS X, I am trying to connect to SqlServer from Cakephp2.0 application but it says "Cake is NOT able to connect to the database."

When I looked into the Cakephp datasource classes, In Sqlserver.php, it was checking for the the available drivers using PDO::getAvailableDrivers(), it was not returning the sqlsrv driver.

Is anyone tried connecting to Sql Server using sqlsrv (Provides access to Microsoft SQL Server database servers. developed, supported by Microsoft) using cakephp2.0 on Mac OS X.

Thanks in advance. Any help will be appreciated.

1 Answer 1

2

Just to clarify, Microsoft's sqlsrv Database Extension only works on Windows.

Also, the PDO_SQLSRV PDO driver that datasource uses only works on Windows:

The PDO_SQLSRV extension is only compatible with PHP running on Windows. For Linux, see ODBC and » Microsoft's SQL Server ODBC Driver for Linux.

There are the alternatives above, but I believe you will probably want to compile FreeTDS to get up and running (potentially following this guide):

PDO_DBLIB is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to Microsoft SQL Server and Sybase databases through the FreeTDS libary.

  • Install Xcode (comes with headers and compiling tools such as gcc, make, etc.)
  • Install a package manager (homebrew, fink, macports)
  • (optional) Install UnixODBC
  • Install FreeTDS (configured to use your built in iODBC or UnixODBC)
  • Configure ODBC settings.

But first of all I would follow this ticket as it seems to offer some advice specifically about CakePHP and what datasource changes may need required.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.