Boss solution vs Developer solution

Posted by mahen23 on Programmers See other posts from Programmers or by mahen23
Published on 2010-12-20T10:30:16Z Indexed on 2012/08/28 3:51 UTC
Read the original article Hit count: 197

Filed under:

The problem: When we were sending newsletters to customers, there was no way to confirm if the customer already received the mail. So the boss decided to implement this idea:

Boss's Idea: Each time mail was being sent, do an INSERT in a db with the title of the newsletter being sent and the email address which is receving the email address. To ensure that any email address does not receive the same email twice, do a SELECT in the table and find the title of the newsletter being sent:

if (title of newsletter is found)
{
  check to see of the email we are sending mail to is already present. if it does, do not send mail
} 
else
{
 send mail
}

MY idea: create a column called unique and mark it as UNIQUE. Each time mail was being sent, concatenate email + newsletter id and record it in the UNIQUE row. The next time we do a "mysql_affected_rows" check to see if our INSERT was successful, we send the mail, else, there is already a duplicate and no need to send it.

© Programmers or respective owner

Related posts about work-environment