I would like to accept conditions in a format that can be used by both PHP's preg_match and MySQL's LIKE operator.
The reason for doing this is that the conditions are used in two different parts of code, one where it's significantly faster to match the condition to the data, and the other where it's significantly faster to match the data to the condition.
I'd like to provide the ability for the user to give something like :
'hostname' 'match' '*.core-*-??.foo.com'
For MySQL it would use:
'%.core-%-__.foo.com'
for preg_match it would use something like:
'/.*\.core-.*-..\.foo\.com$/'
I'm sure someone has already come up with some way of allowing portable matches between these two systems.
The alternative is to use regular expressions in MySQL, but I'm not sure how good an idea that is from a scalability standpoint.
LIKEpattern matching can avoid table scans when the pattern begins with a wildcard (so both will entail full table scans and scale poorly).