I'm trying to build a simple newsletter mailer with multi list capability. The author checks boxes to specify which lists should receive their email and the data is then posted to a script that compiles a queue.
At the moment, I'm using a set of queries to place data into a "buffer" table that will have duplicate addresses in it, then move distinct email addresses along with other data associated with it into the main queue, where it will be sent by cron later.
I think that this is rather a long-winded approach to a simple set of tasks which are as follows:
1. For each checkbox providing a list id, grab data about people who have signed up to it, but...
2. Exclude duplicates (if users are subscribed to more than one list, they'll appear multiple times in the subscribers table)
3. Place the resultant, duplicate-free array of user info into the queue table
Currently, the php script to acheive this is rather bulky and, if I don't use ini_set() to extend the max_execution_time config, the server times out if the queue is big.
Using
Code: Select all
SELECT DISTINCT * FROM mailinglist_subscribers WHERE list_id = "$list_id"I need to select a distinct email address where the user is subscribed to at least one of the (potentially) several list ids that have been posted. Is "distinct" the way to go, or can this be achieved with "limit", or is there a better way?
Thank in advance for your help!