Help guys, I'm new to developing PHP applications on Mac (I developed on Windows before) and I need help installing MAMP Pro's ODBC Driver 17 for SQL Server. I installed the driver following the instructions at https://github.com/Braineee/microsoft-driver-on-mamp-for-mac/blob/master/README.md, but I got a driver not found error.
Extension added in MAMP Pro: MAMP Pro
File copied to MAMP: MAMP Pro
< br />PHP version: 8.1.13
Connection 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);
Connection is normal on Windows WAMP server. On the Mac I tried everything but the driver is not found.
phpinfo() shows that you have installed the PDO_SQLSRV extension. Use it not through ODBC, but through a specific DSN, like this: