I have an issue with exporting BLOB to a csv file using php. Obviously blob is not a normal field, but it is on occasion used. But here's what I need, I need this script to work by taking a table array and export each row in csv format. Blob is screwing this up. I've tried to base64_encode the blob, but I believe that would export the blob incorrectly.
Here is what I have so far:
function exportcsv($tables) {
    foreach ($tables as $k => $v) {
        $fh = fopen('sql/'.$v.'.csv', 'w');
        $sql = mysql_query("SELECT * FROM $v");
        while ($row = mysql_fetch_row($sql)) {
            $line = array();
            foreach ($row as $key => $v) {
                $line[] = base64_encode($v);
            }
            fputcsv($fh, $line, chr(9)); //tab delimiting
        }
        fclose($fh);
    }
}
Any help would be appreciated.
EDIT: Here is an image of the blob export WITHOUT base64_encode(). https://www.strongspace.com/shared/crypok1lxb
So, will base64 protect the format of blob when the need to reimport arises?
 
     
    