Answer the question
In order to leave comments, you need to log in
Prepare statement for like?
Hello everyone, there was a problem with preparing an expression for SQL LIKE ..
There is a query like:
prepare...('SELECT * FROM table WHERE field LIKE '%:like%' ...);
и тут же делаю такой бинд:
$bind['like'] = $myVar
а массив $bind передаю в $pdo->execute($bind)
$pdo->prepare(' SELECT ... LIKE '%text%'..);
Answer the question
In order to leave comments, you need to log in
This is a feature of prepared expressions. It should be like this:
prepare...('SELECT * FROM table WHERE field LIKE :like ...');
$bind['like'] = '%' . $myVar . '%';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question