php - How do you do fuzzy searches using bound parameters in PDO? -
trying sort of thing...
where username '%$str%'
...but using bound parameters prepared statements in pdo. e.g.:
$query = $db->prepare("select * comments comment :search"); $query->bindparam(':search', $str); $query->execute();
i've tried numerous permutations of single quotes , % signs , it's getting cross me.
i seem remember wrestling @ point before can't find references. know how (if?) can nicely in pdo named parameters?
ah. found comment on php.net reminded me of answer; need wildcard value before bindparam evaluated, , not worry quoting it. example works fine:
$str = "%$str%"; $query = $db->prepare("select * comments comment :search"); $query->bindparam(':search', $str); $query->execute();
Comments
Post a Comment