Storing/retrieving binary data with MySQL

wxdqz

New Member
Hi all,

I'm implementing a system in PHP that will allow a research group at our university to build a database of references bibliographies/urls/etc, and I'd also like to let them upload files they'd need.

The server is MySQL. I've got a table with a 'longblob' field to store the data in. I'm using the SELECT INTO DUMPFILE feature in version 3.23, which is supposed to not escape any characters, nor insert any line breaks.

PHP isn't escaping the string, and I've checked to see that text files come out fine, slashes, quotes, and all. They do. However, binary files are corrupt. I checked the file size on the output file versus the input file and it was 539Kb vs. 654kb. This leads me to believe that it's either being stored or dumped into a file as 7-bit (539/654 ~= 7/8). Which one is it? Can I store binary data in mysql fields? If so, is my method of retrieving the data flawed?

Thanks for any help,

Tudor
 
Back
Top