• Resolved Aurovrata Venet

    (@aurovrata)


    Serialized arrays are not being imported into the DB correctly.
    The following serialized string,

    a:4:{i:0;d:21.85;i:1;d:730.8;i:2;d:0.01275;i:3;d:247.337;}

    is being stored as,

    s:58:"a:4:{i:0;d:21.85;i:1;d:730.8;i:2;d:0.01275;i:3;d:247.337;}";

Viewing 3 replies - 1 through 3 (of 3 total)
  • Am having the same problem… I was fed up with the space taken by several checkboxes so replaced them with an array of checkboxes (content gets similarly serialized).

    I got around it because in my case I knew it would always be six strokes added to the front and two to the back (check in your case*): Directly in the database (via phpmyadmin, mysql in my case) I told that column to strip those off… In detail,

    My meta_key was (say) “marcel_data” and my database-prefix was (say) “wpdb_”, so I executed the following sql statement:
    UPDATE wpdb_postmeta SET meta_value=SUBSTRING(meta_value, 6) WHERE meta_key = ‘marcel_data’

    OK, for safety’s sake either first backup the table [easy: export as SQL file, just that table]. Or do it first without changing the data, like

    SELECT id, meta_key, meta_value, SUBSTRING(meta_value, 6) FROM wpdb_postmeta WHERE meta_key = ‘marcel_data’

    [come to think of it, if you’re not used to SQL –like me– just take the exported backup, open in an editor, and use GREP to find the pattern to strip — s:[0-9]+:” see, your “58” can now be “5” or “558” and it all works — then when satisfied drop the table and insert your edited version.]

    Funny thing is that the grammatical error (at the end there’s 2 unwanted characters “;) gets ignored. If you ever edit the field in the admin then save, then the error corrects itself; if not, it’s there but things work. It’s neater if you correct the same, with a SUBSTRING from the end.

    (*lenght to chop off: in your example, the “58” is the total number of keystrokes that follows, will it go beyond 99, to three digits? If so, you may need something smarter either in the WHERE-condition, or instead of SUBSTRING maybe LEN or so first to check)

    Hm… I cannot correct my earlier post if I’m write …err.. right?

    My count was off by one: Substring isn’t zero-indexed. So Substring (abcde, 3) isn’t losing the first three, it’s losing the first two (starting from third place). And a -3 means same but from the end [in this case, same result]. But! There’s an optional second argument that I can use to cut the end off in the same step: Namely how many letters to keep. So I tell it to lose eight in total (six at start, two at end) and we’re done (and I’ve made up my previous sloppyness):

    Here a version that FIRST skips the initial six letters THEN already stops eight letters from the (original) end — and just shows a comparison, doesn’t actually do it (you still need the UPDATE … etc):

    SELECT meta_value, SUBSTRING(meta_value,7, LENGTH(meta_value) -8) FROM wpdb_postmeta where meta_key = ‘marcel_data’

    Hi,

    The serialised field import is resolve on the latest version of WP Ultimate CSV Importer. Kindly update to the latest version and check on the serialised fields import.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Unable to import serialized fields’ is closed to new replies.