title: bindParam for a GET-value for LIKE in a PDO MySQL query
body: <p>Is there any way of converting</p>
  
  <pre><code>$term = $_GET['p'];
  $stmt = $dbh-&gt;prepare("
      SELECT      *
      FROM        posts
      WHERE       heading LIKE '%$term%'
      OR          full_text LIKE '%$term%'
      LIMIT       0 , 30
  ");
  $stmt-&gt;execute();
  $answer = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
  </code></pre>
  
  <p>INTO something like</p>
  
  <pre><code>$term = "'%" . $_GET['p'] . "%'";
  $stmt = $dbh-&gt;prepare("
      SELECT      *
      FROM        posts
      WHERE       heading LIKE :term
      OR          full_text LIKE :term
      LIMIT       0 , 30
  ");
  $stmt-&gt;bindParam(":term", $term);
  $stmt-&gt;execute();
  $answer = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
  </code></pre>
  
  <p>So that I can use <code>bindParam(":term", $term);</code> instead of <code>'%$term%'</code> in the query?</p>
  
  <p>I've already looked at these <a href="https://stackoverflow.com/questions/11068230/using-like-in-bindparam-for-a-mysql-pdo-query">Using LIKE in bindParam for a MySQL PDO Query</a> and  <a href="https://stackoverflow.com/questions/11000576/mysql-pdo-like-statement-not-working-using-bindparam">Mysql, PDO - Like statement not working using bindParam</a>. But they doesn't give me any proper answer for my question.</p>