unserialize data from mysql

前端 未结 1 1312
庸人自扰
庸人自扰 2021-01-21 08:34

in my mysql cell this is stored using serialize function

a:1:{i:0;s:275:\"a:4:{s:8:\"khghg_id\";s:10:\"foo1187\";s:3:\"uri\";s:21:\"foo/vtory/1187\";s:4:\"name\         


        
相关标签:
1条回答
  • 2021-01-21 09:08

    You retrieve a serialized text from database.

    You unserialize it.. change it and then when you save it back to database you need to serialize it back

    //retrieve serialized data from database
    $arr = unserialize($row['properties']);
    
    //get the desired value
    $khghg_id = $arr['khghg_id'];
    
    //now insert $khghg_id in database
    

    From the code you posted above.. I see you are unserializing 2 times.. you dont really need to do this

    $cell =$row9['attachment'];
    $list = unserialize($cell);
    $info = $list[0]; //this line should make the difference
    var_dump($info);
    
    0 讨论(0)
提交回复
热议问题