Page 1 of 1

Introduce array in database

Posted: Sun Mar 06, 2005 2:12 pm
by Perfidus
Which is the better way to introduce an array inside a mysql database?
I generate an array with a list of e-mail adresses I have just send and I want to keep this list any time I send a mailing to keep records of who did I sent them. I want to introduce this e-mail list in a database column call emailed.
Which is the best way, if we consideer the posibility I may like to recover the list easily and make it an array again to resend mails again??

Posted: Sun Mar 06, 2005 2:15 pm
by feyd
each row of this table should be an id, email address, date/time type way of tracking when you last sent them something, and possibly the message id you sent them (assuming these are formulaic in nature mass mailings)

Posted: Sun Mar 06, 2005 3:18 pm
by timvw
as already mentionned:

you need a reference to the e-mail you sent (email_id)
you need a reference to the recipient (e-mail or person_id)

sometimes you also want to optional info:

the time when the e-mail was sent (not the same as the creation date of the e-mail)

..

Posted: Mon Mar 07, 2005 2:14 am
by Perfidus
I didn't explained myself quite well, mates!
I'm sorry.
I have a variable called $unidad which is an array composed by the list of e-mails of the people I have sent an e-mail, I also have a column with name "e-mailed" in which I would like to store this array.
I think the question is:
How to convert the array into a string to be stored in the database and easily converted again in an array again if needed?
The array is a simple one, just e-mails:

1@hotmail.com, 2@hotmail.com, 3@hotmail.com....

Posted: Mon Mar 07, 2005 2:18 am
by feyd
you don't convert the array into a string. Each email is stored as a seperate row.

Posted: Mon Mar 07, 2005 2:23 am
by Perfidus
why?
I'm sending the same e-mail to maybe 50 people, why should I create a table just for the emails? Is it not better to store an array with all the recipients???

Posted: Mon Mar 07, 2005 2:26 am
by feyd
typically, no. What if you want to know the emails you've sent to x,y,z addresses? How easy will it be to construct a query that's simple and works well with it?

If you read this, you may understand why we suggest the things we do. :)

Posted: Mon Mar 07, 2005 2:42 am
by Perfidus
ok, you are right again!

Thanks!