Just came across a subtle problem with using this class within the shared code, and in general will apply to other 'LIKE' mysql queries where you are using underscore _ in field data.
I have 4 DB records.
token_key = 'tile_141_0'
token_key = 'tile_141_1'
token_key = 'tile_14_0'
token_key = 'tile_14_1'
"UPDATE tiles SET bonus=40 WHERE token_key LIKE 'tile_14_%'" - trying to change just the last 2 records.
But this will change ALL 4 records and not just the 14's. Because the underscore is a single character wildcard in LIKE statements and essentially needs to be escaped.
"UPDATE tiles SET bonus=40 WHERE token_key LIKE 'tile\_14\_%'"
I copied an example that uses _ underscores a lot. I think it's best to switch to using - instead to save possible problems.
I have 4 DB records.
token_key = 'tile_141_0'
token_key = 'tile_141_1'
token_key = 'tile_14_0'
token_key = 'tile_14_1'
"UPDATE tiles SET bonus=40 WHERE token_key LIKE 'tile_14_%'" - trying to change just the last 2 records.
But this will change ALL 4 records and not just the 14's. Because the underscore is a single character wildcard in LIKE statements and essentially needs to be escaped.
"UPDATE tiles SET bonus=40 WHERE token_key LIKE 'tile\_14\_%'"
I copied an example that uses _ underscores a lot. I think it's best to switch to using - instead to save possible problems.