An efficient way to save an Array and its Keys to a database

前端 未结 3 600
太阳男子
太阳男子 2020-12-21 01:11

I am trying to save lots of variables to a database and it is getting ridiculous now. I am using PHP and MySQL.

Is there a way, I can get the array value and the arr

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-21 01:45

    Serialize the data and write it to a single field in one table. Then to retrieve the data unserialize it and you are left with an array.

     Then write $serialized to database
    ?>
    

    To retrieve

     First Get $serialized from database
    
    $array = unserialize($serialized);
    ?>
    

提交回复
热议问题