5 Replies Latest reply on Sep 11, 2009 8:06 AM by sean69

    Serialized Data

    sean69 Level 1

      I have a database containing some arrays [actually nested arrays] of data that have been serialized using php serialize() function. [the entire array has been serialized]

       

      is there any way for coldfusion to be able to deserialize this data?

       

      here is a small example:

           a:1:{
           s:15:"info_buyRequest";
           a:6:{s:4:"uenc";
           s:128:"aHR0cDovL3d3dy5jYW5hZGFzYWxzYWNvbmdyZXNzLmNvbS9zaG9wL2J1eS1wYXNzL2EtbGEtY2FydGUtdGlja2V0cy5odG1sP29wdGlvbnM9Y2FydCZfX19TSUQ9VQ,,";
           s:7:"product";
           s:2:"72";
           s:15:"related_product";
           s:0:"";
           s:15:"super_attribute";
           a:1:{i:503;s:2:"24";}
           s:7:"options";
           a:1:{i:73;s:12:"xxxx xxxxxx";}
           s:3:"qty";s:1:"1";}
           }
      

       

      -thanks

      -sean

        • 1. Re: Serialized Data
          Adam Cameron. Level 5

          Sure, but not automatically.

           

          My approach would be to get hold of the specification for the serialisation that PHP is performing, and write a function to reverse it (kind of an obvious statement that one, sorry).  It shouldn't be too complicated.

           

          As PHP is open source, you should be able to get hold of the source for thw deseralise function, which will help you with the necessary logic to write your own version.

           

          I also recommend checking on Google to make sure no-one else has already trod this ground.

           

          --

          Adam

          1 person found this helpful
          • 2. Re: Serialized Data
            Prasanth Kumar.S Level 1

            CF has functions to serialize and deserialize JSON  http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_43.html. if you can pass JSON from PHP, you could directly deserialize the data in CF.

             

            -Prasanth

            1 person found this helpful
            • 3. Re: Serialized Data
              sean69 Level 1

              yes - working on both Google [not a lot out there] and deserializing in php then serializing the data with php & json, it's a little confusing being the first time I have had to work with serialized data, ...  not a lot of luck on either front. 

               

              oh btw, any idea what this is?

              aHR0cDovL3d3dy5jYW5hZGFzYWxzYWNvbmdyZXNzLm NvbS9zaG9wL2J1eS1wYXNzL2EtbGEtY2FydGUtdGlja2V0cy5odG1sP29wdGlvbnM9Y2FydCZfX19TSU Q9VQ?
              • 4. Re: Serialized Data
                Adam Cameron. Level 5

                 

                oh btw, any idea what this is?

                aHR0cDovL3d3dy5jYW5hZGFzYWxzYWNvbmdyZXNzLm NvbS9zaG9wL2J1eS1wYXNzL2EtbGEtY2FydGUtdGlja2V0cy5odG1sP29wdGlvbnM9Y2FydCZfX19TS U Q9VQ?

                It's some binary data that's been serialised.  Like an image or something like that (although there's not enough of it for it to be likely to actually be an image).

                 

                --

                Adam

                • 5. Re: Serialized Data
                  sean69 Level 1

                  it is....  but I have not been able to decode it to anything recognizable - I think it might be paypal return data.... not sure.

                   

                  but the good news is;

                   

                  the php serialized data can be deserialized, and then serialized as wddx data

                   

                  $tmp = unserialize($query['query_col']);
                   print wddx_serialize_vars('tmp'); 
                  

                   

                  written to a file like that cfmx can read that automagically so all I need to do is write a php webservice [argh!?] to provide the wddx serialized data.

                   

                   

                   

                  -sean