MySQL Engines

I flipped through some stuff today describing different MySQL engines and their pros and cons.  It pretty much just reaffirmed my stance: InnoDB is what I would use in most cases because it supports transactions and foreign keys, but if I had a single table I needed to be fast, I might use MyISAM.  That makes sense, right?  Is there anything else I’m missing?

2 comments »

The Magic of similar_text()

So I had this dilemma the other day when I had a report that was displaying “event type”, “event name” and “event location.”  Due to some wonky old data, the event name would frequently be the same as event type or event location (e.g. “Dentist Appt” as type, “Dentist Appointment” as name, and “Dentist’s Office” as location).  It made sense to not show the event name if it only contained redundant information.

Unfortunately, as in the example above, “Dentist Appt” and “Dentist Appointment” are not exactly the same value, even though they have the same human meaning.

Luckily I discovered a handy little php function called similar_text(), which will compare two strings and either return the number of shared characters, or what percentage of the string is the same.  So instead of saying “if event name is equal to event type, don’t show event name,” I now have something like “if event name is 85% similar to event type, don’t show it.”  This seems to work pretty well, so yay! :)

No comments »