将PHP数组存储在Mysql数据库中

时间:2022-04-26 15:41:37

What is the best way to store/retrieve an array in a Mysql database? Is serializing the data the best way?

在Mysql数据库中存储/检索数组的最佳方法是什么?序列化数据是最好的方法吗?

I am looking for neat, nice way to do this.

我正在寻找干净利落的好方法。

1 个解决方案

#1


4  

Serializing is actually a worst way ever.

序列化实际上是有史以来最糟糕的方式。

It is like if you cut a door from your expensive car, and use it as a sleigh, only because being too lazy to get some gas. Mysql is an expensive car and it have to be used properly, and solution have to be not a quick and dirty one but out of reason and knowledge.

就像你从昂贵的汽车上切开一扇门,并将其用作雪橇,只是因为太懒而无法获得燃气。 Mysql是一辆昂贵的汽车,它必须正确使用,解决方案必须不是一个快速和肮脏的,但缺乏理智和知识。

The solution depends on the nature of the data in this array and most likely will involve a separate table (as tables in mysql being pretty much arrays themselves)

解决方案取决于此数组中数据的性质,并且很可能涉及一个单独的表(因为mysql中的表本身就是数组)

#1


4  

Serializing is actually a worst way ever.

序列化实际上是有史以来最糟糕的方式。

It is like if you cut a door from your expensive car, and use it as a sleigh, only because being too lazy to get some gas. Mysql is an expensive car and it have to be used properly, and solution have to be not a quick and dirty one but out of reason and knowledge.

就像你从昂贵的汽车上切开一扇门,并将其用作雪橇,只是因为太懒而无法获得燃气。 Mysql是一辆昂贵的汽车,它必须正确使用,解决方案必须不是一个快速和肮脏的,但缺乏理智和知识。

The solution depends on the nature of the data in this array and most likely will involve a separate table (as tables in mysql being pretty much arrays themselves)

解决方案取决于此数组中数据的性质,并且很可能涉及一个单独的表(因为mysql中的表本身就是数组)