I have a database with a data (.bin/ blob file) stored into it. I'm using the following code to output the data from the .bin file:
function connect_db() {
$server = '****';
$user = '****';
$pw = '****';
$db = '****';
$connect = mysqli_connect($server,$user,$pw,$db);
if(!$connect) {
die('Connection error: '.mysqli_connect_error());
}
return $connect;
}
function get_blob() {
$connect = connect_db();
$query = 'SELECT blob FROM my_table';
$result = mysqli_query($connect, $query);
while($data = mysqli_fetch_assoc($result)) {
header('Content-type: text/plain');
$blob[]=$data;
}
return $blob;
}
echo '<pre>';
print_r(get_blob());
echo '</pre>';
This gives me the following output (this is one of the many values in the array that I get back from the database):
[24] => Array
(
[data] => a:1:{s:7:"context";a:5:{s:11:"product_ids";s:6:"entity";s:19:"add_to_cart_combine";i:1;s:30:"show_single_product_attributes";i:1;s:12:"display_path";s:8:"node/171";s:6:"entity";a:3:{s:11:"entity_type";s:4:"node";s:9:"entity_id";s:3:"171";s:28:"product_reference_field_name";s:14:"field_products";}}}
I was looking for an image, but it seems this blob doesn't contain one. However I still would like to save all this data correctly into an array (multidimensional probably). I was planning to use explode, but that seems a little far fetched. Is there a way for me to get clean data without using explode too much?