<tfoot id='p1cWv'></tfoot>
<legend id='p1cWv'><style id='p1cWv'><dir id='p1cWv'><q id='p1cWv'></q></dir></style></legend>
      <bdo id='p1cWv'></bdo><ul id='p1cWv'></ul>

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

        <i id='p1cWv'><tr id='p1cWv'><dt id='p1cWv'><q id='p1cWv'><span id='p1cWv'><b id='p1cWv'><form id='p1cWv'><ins id='p1cWv'></ins><ul id='p1cWv'></ul><sub id='p1cWv'></sub></form><legend id='p1cWv'></legend><bdo id='p1cWv'><pre id='p1cWv'><center id='p1cWv'></center></pre></bdo></b><th id='p1cWv'></th></span></q></dt></tr></i><div id='p1cWv'><tfoot id='p1cWv'></tfoot><dl id='p1cWv'><fieldset id='p1cWv'></fieldset></dl></div>
      1. Linux 上的 PHP 5.4:如何连接 MS SQL Server 2008?

        时间:2023-10-02
        <tfoot id='XnGzL'></tfoot>

          <tbody id='XnGzL'></tbody>

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

        <legend id='XnGzL'><style id='XnGzL'><dir id='XnGzL'><q id='XnGzL'></q></dir></style></legend>
          • <bdo id='XnGzL'></bdo><ul id='XnGzL'></ul>

                <i id='XnGzL'><tr id='XnGzL'><dt id='XnGzL'><q id='XnGzL'><span id='XnGzL'><b id='XnGzL'><form id='XnGzL'><ins id='XnGzL'></ins><ul id='XnGzL'></ul><sub id='XnGzL'></sub></form><legend id='XnGzL'></legend><bdo id='XnGzL'><pre id='XnGzL'><center id='XnGzL'></center></pre></bdo></b><th id='XnGzL'></th></span></q></dt></tr></i><div id='XnGzL'><tfoot id='XnGzL'></tfoot><dl id='XnGzL'><fieldset id='XnGzL'></fieldset></dl></div>
                  本文介绍了Linux 上的 PHP 5.4:如何连接 MS SQL Server 2008?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一台 Linux 服务器 Debian 6,安装了 Apache 2.2 和 PHP 5.4.我需要将我的应用程序与 MS SQL Server 2008 连接.

                  I have a Linux server Debian 6, with Apache 2.2 and PHP 5.4 installed. I need to connect my application with a MS SQL Server 2008.

                  我的应用程序使用 Zend Framework 1.11 和字符集 UTF-8(我将拥有来自世界各地的用户,他们将使用自己的语言放置数据).

                  My application is using Zend Framework 1.11 and charset UTF-8 (I'll have users from all places in the world and they will put data in their own language).

                  首先,我尝试将 Microsoft SQL Server ODBC 驱动程序用于 Linux.它说仅适用于 Red Hat,但我按照以下说明进行安装:

                  FRIST, I tried to use Microsoft SQL Server ODBC driver for Linux. It says is only for Red Hat, but I follow these instructions to install:

                  http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/

                  我可以连接并对其进行一些选择,但无法在其上插入数据.我在 pdo 语句上绑定参数时遇到问题.

                  I could connect and make some selects on it, but I couldn't insert data on it. I got a problem on binding parameters on pdo statements.

                  插入如下数据无效:

                  $stmt = $conn->prepare("insert into mar_regions (name) values (:name)");
                  $resp = $stmt->execute(array(':name' => $param));
                  

                  但是如果我像这样使用它,它会起作用:

                  But if I used like the this, it works:

                  $stmt = $conn->prepare("insert into mar_regions (name) values ('".$param."')");
                  $resp = $stmt->execute();
                  

                  所以我放弃了这个驱动程序,因为如果这样的话,我的应用程序没有 ZF 1.11 将无法工作.

                  So I gave up from this driver, because my application no ZF 1.11 will not work if this.

                  第二,我尝试将 PDO 驱动程序用于 FreeTDS.这个工作正常,我可以在我的 ZF 1.11 应用程序中使用.

                  SECOND, I try to use PDO Driver for FreeTDS. This one works ok and I could use on my ZF 1.11 application.

                  但是,我又遇到了一个问题:字符集.我将我的 freeTDS.conf 配置为使用 UTF-8,将我的表更改为使用 NVARCHAR insted of VARCHAR,并且可以像这样插入 utf-8 数据:

                  But then, I got one more problem: charsets. I configure my freeTDS.conf to use UTF-8, change my tables to use NVARCHAR insted of VARCHAR and could insert utf-8 data like this:

                  $stmt = $dbh->prepare("insert into mar_teste (name) values (N'ンから初・配信 € зеленый банан ÀÀÀÀáááááá')");
                  $resp = $stmt->execute();
                  

                  但是,在我的 ZF 1.11 上,我无法在查询中传递这个N"属性!所以我的应用程序仍然没有工作.

                  But, on my ZF 1.11, I can't pass this 'N' attribute on querys! So my application still didn't work.

                  如你所见,我什么都试过了.

                  As you can see I tried everything.

                  所以我的问题是:如何在 MS SQL Server 2008 上使用 ZF 1.11 字符集 UTF-8 从 linux 连接?

                  So my question is: How to connect from linux, using ZF 1.11 charset UTF-8, on MS SQL Server 2008?

                  推荐答案

                  我的问题的答案是:使用 freeTDS!上面有一个字符集参数:

                  The answer for my question is: Use freeTDS! Theres a parameter for charset on it:

                  [MyDSN]
                      host = <<ip>>
                      port = <<port>>
                      # use 8.0 for newer versions of SQLSERVER
                          tds version = 8.0
                          # text size don't need to be such a high value, its just an example
                          text size = 4294967295
                          client charset = UTF-8
                  

                  在 Zend Framework 上,像这样配置您的连接:

                  On Zend Framework, configure your connection like this:

                  ;; BANCO DE DADOS LINUX
                  database.adapter                = PDO_MSSQL
                  database.params.pdoType         = dblib
                  
                  database.params.host            = MyDSN
                  database.params.dbname          = <<dbname>>
                  database.params.username        = <<username>>
                  database.params.password        = <<passwd>>
                  database.params.driver_options.charset = UTF-8
                  
                  database.isDefaultTableAdapter  = true
                  

                  它解决了问题!;)

                  这篇关于Linux 上的 PHP 5.4:如何连接 MS SQL Server 2008?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Zend 框架中使用 GROUP_CONCAT? 下一篇:学说 2 和 Zend 分页器

                  相关文章

                  最新文章

                    <bdo id='EOhga'></bdo><ul id='EOhga'></ul>
                    <tfoot id='EOhga'></tfoot>

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

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