title: PHP PDO LIKE : escaping the % character when combining with wildcard
body: <pre><code>$percent = ‘%’;
  $st=$db-&gt;prepare(“SELECT * FROM x WHERE y LIKE ?”);
  $st=$st-&gt;execute(array(‘%’.$percent.’%’)); /*I want to get all records with the string % included like 5% etc.*/
  </code></pre>
  
  <p>The above example will not match correctly, instead matching all records in table x. In order for this to work correctly, I apparently need to set $percent='\%'. </p>
  
  <p>This is where I am left confused about the concept behind prepared statements. I thought the whole point of prepared statements was that the value itself( $percent) would simply be interpreted as a string instead of a special wildcard character. I would appreciate any feedback.</p>
  
  <p>Thanks in advance</p>