PDO : prepare with bindvalue and like %
问题 I've looked over an hour on various website but I couldn't solve my problem. So here is the code that works: $animes = array(); $q = $this->_db->query('SELECT id, nom, nom_id FROM animes WHERE nom LIKE "%code%"'); while ($data = $q->fetch(PDO::FETCH_ASSOC)) { $animes[] = new Anime($data); } return $animes; And here is the one that doesn't work : $animes = array(); $q = $this->_db->prepare('SELECT id, nom, nom_id FROM animes WHERE nom LIKE :n'); $q->bindValue(':n',"%code%",PDO::PARAM_STR);