php - Getting empty query -


this question has answer here:

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 . '%');).

see comment on pdostatement::bindparam.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -