1
Is usually used implode/explode
or serialize/unserialize
to store multiple information of a particular item in the database. Using PDO, which would be the best and whether there is another way to store an array in a single database field?
1
Is usually used implode/explode
or serialize/unserialize
to store multiple information of a particular item in the database. Using PDO, which would be the best and whether there is another way to store an array in a single database field?
Browser other questions tagged php mysql pdo
You are not signed in. Login or sign up in order to post.
It is generally not recommended to create multi-valued columns :P if you really need to and are using Mysql version 5.7 you can create a json-like column.
– rray
Related: What is the purpose of the JSON column in MYSQL?
– rray
@rray, in short, is it right to create a JSON type field in the database? So, how would you store such data using PDO? I use
PDO::PARAM_STR
?– lucasbento
The ideal is to normalize their tables, for example would need a table for news another for categories and an associative to tie a news to several categories. If it is not possible to create a json column, for PDO you can pass as string (
PDO::PARAM_STR
) even.– rray