acctman Posted August 27, 2008 Share Posted August 27, 2008 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) Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 Sections? Please clarify. Quote Link to comment Share on other sites More sharing options...
acctman Posted August 27, 2008 Author Share Posted August 27, 2008 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 That doesn't answer my question... what is the format of this BLOB field? Quote Link to comment Share on other sites More sharing options...
acctman Posted August 27, 2008 Author Share Posted August 27, 2008 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 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. Quote Link to comment Share on other sites More sharing options...
acctman Posted August 27, 2008 Author Share Posted August 27, 2008 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 I still have no idea what the M_addtn field looks like, I'm sorry. You're describing the destination, not hte souce. Quote Link to comment Share on other sites More sharing options...
acctman Posted August 27, 2008 Author Share Posted August 27, 2008 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 29, 2008 Share Posted August 29, 2008 thats the order it appears on the site so i'm assuming thats the way its being saved in that order. You assume? Didn't you check? How are they separated? Quote Link to comment Share on other sites More sharing options...
acctman Posted August 29, 2008 Author Share Posted August 29, 2008 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted August 30, 2008 Share Posted August 30, 2008 Why bother doing it all in sql since you're already forced to deserialize() in php?` Quote Link to comment Share on other sites More sharing options...
acctman Posted August 31, 2008 Author Share Posted August 31, 2008 Why bother doing it all in sql since you're already forced to deserialize() in php?` i thought sql would be faster since there is over 80,000+ rows to process. do you know how to process it with php? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 31, 2008 Share Posted August 31, 2008 Well, if you can't unserialize() in mysql, then you're stuck. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.