title: Kohana PHP, ORM and MySQL BLOBs
body: <p>I'm trying to create and retrieve a BLOB in a MySQL table via Kohana's ORM library.</p>
  
  <p>The code looks something like:</p>
  
  <pre><code>$attachment = new Attachment_Model();
  $attachment-&gt;name = $info['FileName'];
  $attachment-&gt;size = strlen($info['Data']);
  $attachment-&gt;data = $info['Data'];
  $attachment-&gt;mime_type = $info['content-type'];
  $attachment-&gt;save();
  </code></pre>
  
  <p>I've verified that the data is OK at this point by outputting it to a file. However, when I retrieve the data it comes out corrupted. I've managed to narrow this down a bit more - I've used the MySQL query tool to extract the data as held in the database and I can verify that the data in the database is corrupt, so the problem must be on the INSERT.</p>
  
  <p>Also, the files inputted aren't always corrupt - smaller files (such as images) tend to be OK.</p>
  
  <p>Anyone have any ideas?</p>