The user can enter keywords in the text field and separate the keys with a comma.
So the input may be bananas, apple, orange, pineapple.
In my database, I have a table named keyword, and it contains only one column keyword, which is also the primary key.
I add keywords to the database $myArray = expload(',', $keywords).
Then I iterate over the array and do `INSERT INTO myTable '.
Now, if the keyword already exists, I will get an error.
I can overcome the error message using the instructions INSERT IGNORE INTO. If the record is a duplicate, the IGNORE keyword tells MySQL to cancel it without any errors.
My question is: is this a good way to do this? Or should I first check if a keyword exists?
I kind of think two questions against one. And will this affect server load?
source
share