I have a table called artists. Within it, there is a field for the artist name (artist_name). Then there is a field for SEO friendly artist name, we’ll call it search_name.
I have over 40,000 artists in this table. So, I’d like to convert all artists names to search friendly. What is the best way to accomplish this? Not looking for code here, just ideas.
This is what I have thus far. I’m just not sure if I should call all 40,000 artists, loop through them and update?
// Does this artist name have any symbols, apostrophes, etc. If so, strip them out
// Does this artist have a space (the beatles)? If so, replace with + (the+beatles).
// insert into search field
As 40,000 records aren’t that much, I’d grab all of them and loop through them in memory. By doing it in memory, unique checks should be pretty fast.
In the end, I’d just chain the commands together like: $query .= “UPDATE artists SET search_name = $generated_name[$i] WHERE id = $id[$i];”.
By the way: I’d replace spaces with a minus.