Jump to content

Storing array's in MySQL with PHP


siwelis

Recommended Posts

I'm thinking about storing some php arrays in mysql using serialize and unserialize... But I'm wondering if this is really a good idea... Does anyone have any light to shed on my situation?

 

If necessary, I could break the arrays down into separate tables... but I really don't like having to access a bunch of different tables per page load.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/196127-storing-arrays-in-mysql-with-php/
Share on other sites

If the arrays have absolutely NO relation to one another (i.e. don't have common values) and you will NEVER need to query based upon those values the go ahead and serialize them. But, if that is not the case, then you should definitely store them in a separate, associated table. I wouldn't think you would need multiple tables (unless you are talking about multiple fields with different arrays).

 

If necessary, I could break the arrays down into separate tables... but I really don't like having to access a bunch of different tables per page load.

 

Why is that? It will be more efficient to have a separate table with the associated data and to get it in a single query than to have to query serialized values and then to unserialize it on-the-fly. Not to mention you lose the integrity of your data. Are you not comfortable using JOINs?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.