php - what's the point of serializing arrays to store them in the db? -


i see people store arrays like:

a:6:{i:0;s:5:"11148";i:1;s:5:"11149";i:2;s:5:"11150";i:3;s:5:"11153";i:4;s:5:"11152";i:5;s:5:"11160";}

why can't be:

11148,11149,11150,11153...

and have sql "type" "array" ?

this way it's shorter , can change values directly in databse without having alter "s:" or "i:".

i've not seen whole lot. it's done implementation ease. serializing data allows store quasi binary data.

your second example csv scheme. workable storing confined string lists. while it's easier query or modify within database, makes more effort unmarshalling from/to database api. there limited list support anyway. http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_find-in-set

however, true, serialized data unneeded in example. it's requirement if need store complex or nested array structures. , in such cases data blob seldomly accessed or queried within database.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -