title: Doctrine 2.3 - text field is not saved because of special characters
body: <p>I've spent hours to debug an algo and noticed it was coming from Doctrine (v2.3.3).
  I'm using libpuzzle to calculate a hash of an image and store this hash in the database.
  The hash returned has special character in it and apparently Doctrine doesn't like it.</p>
  
  <p>This is the kind of string I have (~550 char):</p>
  
  <blockquote>
    <p>ÿ�þÿÿþ�þþÿþÿþÿþþ�þÿþÿÿÿ�ÿþþÿþÿ�ÿÿþÿþÿþþÿþþÿÿÿþÿþþþþÿþ�þþþÿ�ÿÿ�ÿÿþ�þÿþÿþÿþÿþþÿþÿÿÿþþÿþþþþÿþþþþ���ÿÿ�ÿ�þþ�þÿÿþþþÿÿþÿþþÿþþþÿþ...</p>
  </blockquote>
  
  <p>I've investigated and found some people saying to add the charset in the config but I already have it:</p>
  
  <pre><code># Doctrine Configuration
  doctrine:
      dbal:
          driver:   "%database_driver%"
          host:     "%database_host%"
          port:     "%database_port%"
          dbname:   "%database_name%"
          user:     "%database_user%"
          password: "%database_password%"
          charset:  UTF8
  </code></pre>
  
  <p>If I change the collation of the column from <code>utf8_unicode_ci</code> to <code>utf8_general_ci</code> still not working. Also I've made sure that the default schema collation is <code>utf8_general_ci</code>.</p>
  
  <p>I've tried another string with special characters:</p>
  
  <blockquote>
    <p>Test !§$%&amp;/()=? äöü ÄÖÜ :D</p>
  </blockquote>
  
  <p>This string is inserted correctly but the hash still not.</p>
  
  <p>Does anyone know where I could look to fix this issue? Is it a Doctrine bug?</p>
  
  <p><strong>----------------------------------</strong></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Just before the execute I still have the correct data binded. So I guess it's a encoding or driver issue. I've modified the symfony configuration:</p>
  
  <pre><code># Doctrine Configuration
  doctrine:
      dbal:
          driver:   "%database_driver%"
          host:     "%database_host%"
          port:     "%database_port%"
          dbname:   "%database_name%"
          user:     "%database_user%"
          password: "%database_password%"
          charset:  UTF8
          options:
              1002: "SET NAMES 'UTF8'"
  </code></pre>
  
  <p>I've also tried to execute the query without using entities to be sure:</p>
  
  <pre><code>$this-&gt;db = $this-&gt;getContainer()-&gt;get('doctrine')-&gt;getConnection();
  
  $img = '/var/www/acme/web/upload/tmp/cd1fa593cf6feb2cde83e68f461a2d947.jpg';
  $hash = puzzle_fill_cvec_from_file($img);
  
  $sql = "UPDATE image set hash=? WHERE id=?";
  $stmt = $this-&gt;db-&gt;prepare($sql);
  
  $stmt-&gt;execute(array($hash, 180));
  </code></pre>
  
  <p>Still empty data in the database. 
  In another project I've used <code>Zend_Db</code> and didn't have any trouble saving this hash.
  I don't know if it's a bug in <code>Doctrine</code> or not :(</p>
  
  <p><strong>----------------------------------</strong></p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>I've logged all the queries in mysql and I can see in the log that the content is binded correctly. but not saved properly by mysql.</p>
  
  <pre><code>INSERT INTO image (guid, type, createTime, updateTime, images, imageSize, imageHash, status) 
  VALUES (
  'c30df23d6b0b08aff079287e00f21ec8a', 
  'image', 
  '2013-04-22 03:30:33', 
  '2013-04-22 03:30:34',
  'path/image.jpg', 
  '165458', 
  '?\0????\0?????????\0??????\0??????\0??????????????????????\0????\0??\0???\0???????????????????????????\0\0\0??\0?\0??\0??????????????????\0\0\0??\0?\0???????????????\0?????????????????\0?\0????????????\0?\0??????????????????????????\0?\0???????????\0???\0?????????\0??????\0\0?????????????????????\0\0??????\0???????????????\0', 
  1)
  </code></pre>
  
  <p>This is my create table:</p>
  
  <pre><code>delimiter $$
  CREATE TABLE `image` (
    `id` bigint(20) NOT NULL AUTO_INCREMENT,
    `guid` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `createTime` datetime NOT NULL,
    `updateTime` datetime DEFAULT NULL,
    `images` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `imageSize` bigint(20) DEFAULT NULL,
    `imageHash` longtext COLLATE utf8_unicode_ci,
    `status` integer(10) NOT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci$$
  </code></pre>
  
  <p>Cheers,
  Maxime</p>