Jump to content

Convert BLOB to separate fields


acctman

Recommended Posts

Hi can someone assistant me with creating an conversion script. I datab1 four different sections of data in kept in FIELD m_addtn, BLOB format type. My new database datab2, has everything separate how can I process all the entries in datab1 to datab2 inserting the info in the proper field. each table

 

datab1: rate_rmy

table: rate_mem

field: m_addtn (type: blob / attib: binary)

 

datab2: rmb_test

table: rate_mem

field: m_status (type: enum(', 'Choice1', 'Choice2', 'Choice3', 'Choice4', 'Choice5', 'Choice6', 'Choice7', 'Choice8') )

m_ori (type: enum(', 'Other1', 'Other2', 'Other3', 'Other4', 'Other5') )

m_turn1 (type: text)

m_turn2 (type: text)

Link to comment
Share on other sites

Sections? Please clarify.

 

correctly right now in datab1 field m_addtn all for fields are stored within it, in a binary BLOB type format

for datab2 i'm want to use separate fields for each section in the BLOB field of m_addtn.

 

This is how I'm assuming a conversion script would work

 

Connect and open datab1 go to table rate_mem

foreach row copy all fields to datab2 (rmb_test) table rate_mem

and when it gets to field m_addtn in datab1 decode the BLOB binary type and place the results in the apporiate fields in datab2 starting with m_status then m_ori, m_turn1, m_turn2

Link to comment
Share on other sites

That doesn't answer my question... what is the format of this BLOB field?

the atrribute for it says BINARY, thats all that is list Field: m_addtn Type: blob Attribute: binary Null: No

The format of the data being stored inside this field.

Link to comment
Share on other sites

That doesn't answer my question... what is the format of this BLOB field?

the atrribute for it says BINARY, thats all that is list Field: m_addtn Type: blob Attribute: binary Null: No

The format of the data being stored inside this field.

 

sorry for being so new to this. the first two entries should be drop down menu values and then the last two are text.

Link to comment
Share on other sites

I still have no idea what the M_addtn field looks like, I'm sorry.  You're describing the destination, not hte souce.

 

the source is the same way two dropdown boxes and two textboxes were used to fill the BLOB fields. there should be 4 entries inside first one is equal to m_status, second equal to m_ori, and third and fourth are the two textboes m_turn1 and m_turn2.

 

thats the order it appears on the site so i'm assuming thats the way its being saved in that order.

Link to comment
Share on other sites

this is what i ended up doing (see below) it worked in decoding the BLOB and showing me the four entries.

 

<?php

$dbc = mysql_connect ($db_server, $db_user, $db_pass);

mysql_select_db ($db_name) or die(mysql_error());

 

$res = mysql_query("SELECT m_addtn FROM rate_members WHERE m_id = '39'");

$results = mysql_fetch_array($res,MYSQL_BOTH);

 

$decode = unserialize(base64_decode($results['m_addtn']));

print_r($decode);

?>

 

here's what I still need to do, and maybe you can help me with an all sql coded version that I can process inside of phpmyadmin.

 

this is the output data from the above query

Array ( [3] => Single [6] => Involved [4] => I ADDED SOME NEW PICS [1] => THEY R IN THE MAIN 4 NOW ) 

 

To make things similar I've decided to do all the merging in on database, so I've created m_status, m_ori, m_turn1 and m_turn2 in the same table as m_addtn. What I want to do is create a loop that will go to each row and decode the m_addtn field then take the 4 arrays with data in them an insert into the fields. So Array[3] would insert into m_status, Array[6] into m_ori, Array[4] into m_turn1 and Array[1] into m_turn2

 

Can that be done with an all sql code or will i have to use php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.