MacOS MAMP Pro supports Microsoft ODBC Driver 17 for SQL Server.
P粉594941301
2023-08-08 13:37:00
<p>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. <br /><br />Extension added in MAMP Pro: MAMP Pro<br /><br />File copied to MAMP: MAMP Pro<br />< br />PHP version: 8.1.13</p><p>Connection to MSSQL server:</p><p><br /></p>
<pre class="brush:php;toolbar:false;">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);</pre>
<p>Connection is normal on Windows WAMP server. On the Mac I tried everything but the driver is not found. </p><p><br /></p>
phpinfo() shows that you have installed the PDO_SQLSRV extension. Use it not through ODBC, but through a specific DSN, like this: