title: PHP 5.4 on Linux: How to connect with MS SQL Server 2008?
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>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:</p>
  
  <p><a href="http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/" rel="nofollow">http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/</a></p>
  
  <p>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.</p>
  
  <p>Insert data like the following didn't work:</p>
  
  <pre><code>$stmt = $conn-&gt;prepare("insert into mar_regions (name) values (:name)");
  $resp = $stmt-&gt;execute(array(':name' =&gt; $param));
  </code></pre>
  
  <p>But if I used like the this, it works:</p>
  
  <pre><code>$stmt = $conn-&gt;prepare("insert into mar_regions (name) values ('".$param."')");
  $resp = $stmt-&gt;execute();
  </code></pre>
  
  <p>So I gave up from this driver, because my application no ZF 1.11 will not work if this.</p>
  
  <p>SECOND, I try to use PDO Driver for FreeTDS. This one works ok and I could use on my ZF 1.11 application.</p>
  
  <p>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:</p>
  
  <pre><code>$stmt = $dbh-&gt;prepare("insert into mar_teste (name) values (N'ンから初・配信 € зеленый банан ÀÀÀÀáááááá')");
  $resp = $stmt-&gt;execute();
  </code></pre>
  
  <p>But, on my ZF 1.11, I can't pass this 'N' attribute on querys! So my application still didn't work.</p>
  
  <p>As you can see I tried everything.</p>
  
  <p><strong>So my question is</strong>: How to connect from linux, using ZF 1.11 charset UTF-8, on MS SQL Server 2008?</p>