Max Semenik wrote:
- We could use tricky float constants such like 3253427569845.236156471, as suggested by Aryeh Gregor, but it looks rather hackish.
That would introduce an easter egg, where special user input produces unexpected output. It could even be a DoS vector.
Can there be a better way of doing that? And which variant of constant names would you prefer: Mr.Z-man's original LIKE_UNDERSCORE/LIKE_PERCENT, MATCH_CHAR/MATCH_STRING proposed by me, or something else?
Please opine.
I think the function should be buildLike() instead of like(), following the precedent of buildConcat() and the convention that function names should be verb phrases.
Instead of MATCH_CHAR or LIKE_UNDERSCORE I would go for $dbr->anyChar() and $dbr->anyString():
function anyChar() { return new Database_RawLike( '_' ); } function anyString() { return new Database_RawLike( '%' ); }
Then a DBMS which needs to change these special characters could do so by overriding those functions.
I think the function of MATCH_CHAR is rather non-obvious from its name, especially if you don't know SQL and don't know what LIKE clauses are. It looks like a flag, affecting the whole function, instead of a concatenated item.
-- Tim Starling