<small id='GkSzR'></small><noframes id='GkSzR'>

      <tfoot id='GkSzR'></tfoot>
    1. <legend id='GkSzR'><style id='GkSzR'><dir id='GkSzR'><q id='GkSzR'></q></dir></style></legend>
        <i id='GkSzR'><tr id='GkSzR'><dt id='GkSzR'><q id='GkSzR'><span id='GkSzR'><b id='GkSzR'><form id='GkSzR'><ins id='GkSzR'></ins><ul id='GkSzR'></ul><sub id='GkSzR'></sub></form><legend id='GkSzR'></legend><bdo id='GkSzR'><pre id='GkSzR'><center id='GkSzR'></center></pre></bdo></b><th id='GkSzR'></th></span></q></dt></tr></i><div id='GkSzR'><tfoot id='GkSzR'></tfoot><dl id='GkSzR'><fieldset id='GkSzR'></fieldset></dl></div>

        • <bdo id='GkSzR'></bdo><ul id='GkSzR'></ul>

        如何使用 PHP PDO 从 Mac 连接到 Sql Server?

        时间:2023-10-05
          <tbody id='CpzXL'></tbody>

        <small id='CpzXL'></small><noframes id='CpzXL'>

        <tfoot id='CpzXL'></tfoot>

            1. <i id='CpzXL'><tr id='CpzXL'><dt id='CpzXL'><q id='CpzXL'><span id='CpzXL'><b id='CpzXL'><form id='CpzXL'><ins id='CpzXL'></ins><ul id='CpzXL'></ul><sub id='CpzXL'></sub></form><legend id='CpzXL'></legend><bdo id='CpzXL'><pre id='CpzXL'><center id='CpzXL'></center></pre></bdo></b><th id='CpzXL'></th></span></q></dt></tr></i><div id='CpzXL'><tfoot id='CpzXL'></tfoot><dl id='CpzXL'><fieldset id='CpzXL'></fieldset></dl></div>

                <bdo id='CpzXL'></bdo><ul id='CpzXL'></ul>
                1. <legend id='CpzXL'><style id='CpzXL'><dir id='CpzXL'><q id='CpzXL'></q></dir></style></legend>
                2. 本文介绍了如何使用 PHP PDO 从 Mac 连接到 Sql Server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如果你在谷歌上搜索这个问题,你会发现很多不正确、误导性和过时的信息.令人惊讶的是,Stack Overflow 上没有可靠的答案,所以我们应该改变它.

                  If you search Google for this question, you will find a lot of incorrect, misleading, and outdated information. Surprisingly, there isn't a solid answer on Stack Overflow, so we should change that.

                  我使用的是 Mac 端口安装的 Apache 和 PHP.我已经安装了 php5-mssql,我可以在我的 phpinfo() 页面上看到 mssql.

                  I am using the Mac port installation of Apache and PHP. I have installed php5-mssql, and I can see mssql on my phpinfo() page.

                  但我没有看到它列在 PDO 下.

                  But I don't see it listed under PDO.

                  PDO support enabled
                  PDO drivers     dblib, mysql, odbc, pgsql 
                  

                  mssql 与 PDO 无关吗?是否有其他驱动程序可以在 Mac 上使用 PDO 连接到 SqlServer 数据库?看起来这应该是可能的.

                  Is mssql not associated with PDO? Is there another driver that can be used on a Mac to connect to a SqlServer database using PDO? Seems like this is something that should be possible.

                  推荐答案

                  这对您有帮助吗?

                  http://blog.nguyenvq.com/2010/05/16/freetds-unixodbc-rodbc-r/

                  我使用 FreeTDS 从 Linux 服务器连接到 Microsoft SQL 服务器,看起来上面链接中的人使用 FreeTDS 从 Mac 连接.

                  I use FreeTDS to connect to Microsoft SQL servers from a Linux server and it looks like the person in the link above has used FreeTDS to connect from a Mac.

                  这是我的/etc/freetds/freetds.conf 文件(我添加的唯一部分是在 XYZ 服务器的最后):

                  Here is my /etc/freetds/freetds.conf file (the only part I added was at the very end for the XYZ server):

                  [global]
                          # TDS protocol version
                  ;       tds version = 4.2
                  
                          # Whether to write a TDSDUMP file for diagnostic purposes
                          # (setting this to /tmp is insecure on a multi-user system)
                  ;       dump file = /tmp/freetds.log
                  ;       debug flags = 0xffff
                  
                          # Command and connection timeouts
                  ;       timeout = 10
                  ;       connect timeout = 10
                  
                          # If you get out-of-memory errors, it may mean that your client
                          # is trying to allocate a huge buffer for a TEXT field.  
                          # Try setting 'text size' to a more reasonable limit 
                          text size = 64512
                  
                  # Define a connection to the MSSQL server.
                  [xyz]
                          host = xyz
                          port = 1433
                          tds version = 8.0
                  

                  [由提问者编辑]

                  FreeTDS 配置是答案的前半部分.配置完成后,您应该能够从命令行运行类似的操作并进行连接:

                  FreeTDS configuration is the first half of the answer. Once it's configured you should be able to run something like this from the command line and connect:

                  tsql -S xyz -U username -P password
                  

                  那么你需要使用dblib,而不是mssql作为PDO驱动:

                  Then you need to use dblib, not mssql, as the PDO driver:

                  $pdo = new PDO("dblib:host=$dbhost;dbname=$dbname",
                                  "$dbuser","$dbpwd");
                  

                  其中 $dbhost 是 freetds.conf 文件中的名称

                  Where $dbhost is the name from the freetds.conf file

                  这篇关于如何使用 PHP PDO 从 Mac 连接到 Sql Server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PDO 和 MariaDB 下一篇:在 PHP 中创建到 PDO 的连接时出错

                  相关文章

                  最新文章

                  <small id='LxMJB'></small><noframes id='LxMJB'>

                    <bdo id='LxMJB'></bdo><ul id='LxMJB'></ul>

                    <i id='LxMJB'><tr id='LxMJB'><dt id='LxMJB'><q id='LxMJB'><span id='LxMJB'><b id='LxMJB'><form id='LxMJB'><ins id='LxMJB'></ins><ul id='LxMJB'></ul><sub id='LxMJB'></sub></form><legend id='LxMJB'></legend><bdo id='LxMJB'><pre id='LxMJB'><center id='LxMJB'></center></pre></bdo></b><th id='LxMJB'></th></span></q></dt></tr></i><div id='LxMJB'><tfoot id='LxMJB'></tfoot><dl id='LxMJB'><fieldset id='LxMJB'></fieldset></dl></div>

                    1. <legend id='LxMJB'><style id='LxMJB'><dir id='LxMJB'><q id='LxMJB'></q></dir></style></legend>

                      <tfoot id='LxMJB'></tfoot>