Project

General

Profile

Unable to use % wildcard in LIKE statement with non-string value

Added by Alistair Lowe almost 11 years ago

Hi guys,

I'm having a little trouble with creating a LIKE search query with non-string types when using wildcards.

I have a text search box, where the value entered may be numerical etc. If I go through the trouble of identifying the appropriate data type and converting it from a string, then placing it in the bind function, I'm unable to place % or '' in the where function, preventing the use of wildcards.

If, on the other-hand, I bind the value directly as a string, Wt transmits strings to SQL (or at least MySQL) appended with a '\0', preventing them from working with non-string field types.

It seems to me the simplest, speediest and most flexible solution is perhaps to remove the trailing \0 from strings transmitted by Wt? Otherwise a more roundabout approach would be allow '' and % to be placed inside the where statement.

Does this sound about right?

Cheers