php - Mass email id duplicate check -
i have table(email_list) following columns
id int (auto increment), email var char, status tiny-int
user has form has 1 field can upload csv csv contains 1 column email ids
csv contains min 100 , max 500 email ids.
when user click on upload button
1) want check email(s) present in csv exist in email_list table
2) check emails duplicate in csv or not
if no duplicates found then only can insert email ids in table
if duplicates found i want display error message list of emails exist in email_list table , if email duplicate in csv.
i using code igniter , mysql
how can achieve this?
what if email_list table has 5000+ rows , uploading csv contains 500 email ids
- insert ignore not applicable (if no duplicates found can insert email ids in table)
comparison operation took time
please me!!
check database ids first:
select email email_list id in (1,2,3,4,5,6)
you can populate list of ids before query.
$user_ids = array(); foreach($users $user) { $user_ids[] = $user->id; } // query here if(count($res) > 0) { foreach($res $row) { echo "duplicate email: {$row->email}"; } } else { // insert }
Comments
Post a Comment