php - Getting empty query -
this question has answer here:
- mysql pdo how bind like 6 answers
i'm trying pdo query running, i'm doing:
$src = $this->conn->prepare("select name, model, software product model '%:search_string%' or name '%:search_string%' or software '%:search_string%'"); $src->bindparam(':search_string', $search_string); $src->execute(); return $src->fetchall(); but when var_dump this, empty array ( [] ). however, if change "select name, model, software product", of products, expected, how using like clause wrong? or doing wrong?
bound parameters cannot used in way. have input like :search_string in prepared query, add percent signs in bound value (i.e. $src->bindparam(':search_string', '%' . $search_string . '%');).
Comments
Post a Comment