MacOS MAMP Pro支持的是Microsoft ODBC Driver 17 for SQL Server。
<p>大佬们帮帮忙,我在Mac上开发PHP应用程序是新手(之前我在Windows上开发),我需要帮助安装MAMP Pro的ODBC Driver 17 for SQL Server。我按照https://github.com/Braineee/microsoft-driver-on-mamp-for-mac/blob/master/README.md上的说明安装了驱动程序,但是出现了驱动程序未找到的错误。<br /><br />在MAMP Pro中已添加了扩展:MAMP Pro<br /><br />文件已复制到MAMP中:MAMP Pro<br /><br />PHP版本:8.1.13</p><p>连接到MSSQL服务器的:</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>在Windows的WAMP服务器上连接是正常的。在Mac上,我尝试了所有方法,但是驱动程序未找到。</p><p><br /></p>