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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.