Afin de faire une recherche LIKE avec PDO, j'ai besoin d'ajouter le %
au paramètre avant de le passer.Comment faire la recherche LIKE avec PDO?
Cela fonctionne:
$qry = '
SELECT product_id
FROM cart_product
WHERE product_manufacturer_num LIKE :search_string
';
$sth = $this->pdo->prepare($qry);
$sth->execute(array("search_string"=>'%'.$search_string.'%'));
Pour moi, cela ressemble plus à un hack, est-il une façon plus officielle de le faire?
Dupliquer de: http://stackoverflow.com/questions/583336/how-do-i-create-a-pdo-parameterized-query-with-a-like-statement-in-php/7357296#7357296 – Kzqai