This is up to the user of the layer, that's why I need to know if he passed a literal string or number. And to be able to warn him if necessary.
Ok ... so you firstly need to know which option the user has chosen.
Having determined that, I would have thought you could just pass on that user-supplied argument as "$x" (if string was chosen) or "$x"+0 (if integer was chosen) without any need to analyse just what that argument was.
But I've never worked with databases so you should probably simply ignore me (and perhaps even be envious ;-)