MyBB Community Forums

Full Version: working with BLOB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have an empty table that uses BLOB type. When I look as sample data in phpmyadmin, that BLOB is a link and when I click it, I get a file.bin. That file is a simple text file that is basically a serialized array. 

Now, I need to convert a list of data into that table's BLOB field. I can build an array and serialize it, but BLOB needs a "file" to use with the LOAD_FILE function in the INSERT statement, correct?

My understanding is that the LOAD_FILE just reads the contents into a string and then inserts that data. Do I need to write a temp file for every BLOB and every record I want to insert or can I do it some other way?

Sorry, I have never messed with BLOB in the past when it comes to converting this type of data. Reading existing image files or whatever is simple, but this is different for me.

is it really as simple as this:

$data = array('a', 'b', 'c');
$serialized = serialize($data);

$sql = "INSERT INTO ".$table." (someBLOBfield) VALUES(".$serialized.");";

and execute that query?

nevermind, i figured it out. I was dumping the data in phpmyadmin without unchecking the "dump binary in hexadecimal" advanced option, so i was trying to deal with that conversion.

I just need to follow my example above