title: Is a BLOB converted using the current/default charset in MySQL?
body: <ol>
  <li>I have a table with a BLOB field.</li>
  <li>The charset of the table is Latin1.</li>
  <li>I connect to the DB and "SET CHARACTER SET utf8".</li>
  <li>Then I save binary data into the field.</li>
  <li>Then I retrieve the data, and it's not what I saved (corrupt).</li>
  </ol>
  
  <p>The code:</p>
  
  <pre><code>&lt;?php
  $pdo = new \PDO("mysql:host=127.0.0.1;dbname=***", '***', '***');
  
  $pdo-&gt;exec('SET CHARACTER SET utf8');
  
  $sql = "INSERT INTO pdo_blob (the_blob) VALUES(:the_blob)";
  $insertStm = $pdo-&gt;prepare($sql);
  
  $blob = (binary) file_get_contents('/home/***/test.pdf');
  $insertStm-&gt;bindParam(":the_blob", $blob, \PDO::PARAM_LOB);
  $insertStm-&gt;execute();
  
  $selectStm = $pdo-&gt;prepare("SELECT the_blob FROM pdo_blob ORDER BY id DESC LIMIT 1");
  $selectStm-&gt;execute();
  
  $savedBlob = null;
  $selectStm-&gt;bindColumn(1, $savedBlob, \PDO::PARAM_LOB);
  $selectStm-&gt;fetch();
  
  echo 'equal: ' . ((int) ($blob == $savedBlob));
  </code></pre>