Millar Posted December 31, 2006 Share Posted December 31, 2006 I know quite a lot about MySQL but I have never needed to use an array as a mysql value.I need to do this so my personal messaging system will allow sending messages to multiple recipients.Now, really don't know how to go about using an array as a mysql field type. So if anyone could tell me what type of field I need and how to insert/retreive information using php, that would be really helpful.Thanks in advanced,Millar. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 31, 2006 Share Posted December 31, 2006 There is no such thing -- if you're trying to store a bunch of uids in a single column, you're better off with a separate table. Quote Link to comment Share on other sites More sharing options...
artacus Posted January 1, 2007 Share Posted January 1, 2007 Like Fenway suggested, you're probably asking the wrong question. I seriously doubt that you NEED to do this. I'm guessing what you really want to do is store a PHP array. In which case, you can either store the values as a comma separated list, and explode() it when you retrieve it. Or, if you have more complex arrays, serialize() it and store that text in the database.But if you take that approach, you are ultimately selling yourself/employer/clients short. Later if you need to go back and see who received a specific message or see stats on messages received by dept, or whatever, you'd be pretty much helpless. Instead do like fenway said, add a recipients table. It only needs two or maybe 3 fields, message_id, recipient_id, and possibly status_id.You'll need to use another database such as PostgreSQL if you HAVE to use arrays. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 3, 2007 Share Posted January 3, 2007 IMHO, the only time storing a values list in a single field is acceptable is when you never need to read/alter any of the individual values Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.