Microsoft ODBC Driver 17 for SQL Server on MacOS MAMP Pro

146 Views Asked by At

anyone please can help me? I'am new in developing php appliacations on mac (till now I developed on windows) and I need help with installing ODBC Driver 17 for SQL Server for MAMP Pro. I installed the driver according to the instructions on https://github.com/Braineee/microsoft-driver-on-mamp-for-mac/blob/master/README.md and the error is that the driver was not found.

Here are screenshot from phpinfo: phpinfo phpinfo

Extension in MAMP Pro are added: MAMP Pro

Files are copied into MAMP: MAMP Pro

PHP version: 8.1.13

How I'am connecting to MSSQL Server:

private const SQLdriver = 'ODBC Driver 17 for SQL Server';
private const SQLserver = '192.168.1.12';
private const SQLport = 1433;
private const SQLDBName = '?';
private const SQLusername = '?';
private const SQLpassword = '?';
private const SQLparameters = 'TDS_Version=8.0;ClientCharset=UTF-8;';
private const SQLDriverOptions = [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL];

$dsn = 'DRIVER=' . self::SQLdriver . ';' . 'SERVER=' . self::SQLserver . ';' . (empty(self::SQLport) ? '' : 'PORT=' . self::SQLport . ';') . 'DATABASE=' . ($this->dbType === Marfos::DB_TYPE_MAIN ? self::SQLDBName : self::SQLDBNameTest) . ';' . self::SQLparameters;
$this->pdo = new PDO("odbc:" . $dsn . "", self::SQLusername, self::SQLpassword);
$this->pdo->setAttribute(PDO::ATTR_CURSOR, PDO::CURSOR_SCROLL);

The connection on windows WAMP server is good. On mac I tried everything, but the driver was not found.

Thank you very much for your answers.

I searched all webs and tried everyrthing to install the ODBC Driver a I expect help.

1

There are 1 best solutions below

1
Olivier On

Your phpinfo() shows that you have the PDO_SQLSRV extension installed. You don't use it through ODBC but via a specific DSN, e.g.:

$pdo = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password");