VoidStack
VoidStack

Reputation: 3098

Mac OS X + cakephp + SqlServer

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.

Upvotes: 1

Views: 1678

Answers (1)

deizel.
deizel.

Reputation: 11212

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.

Upvotes: 2

Related Questions