title: PDO Binding Limit
body: <p>So I have the following</p>
  
  <pre><code>public function search($table, $column, $term, $limit = 5){
          $command = "SELECT name FROM `$table` WHERE `:col` LIKE :term LIMIT :lim";
          $query = $this-&gt;connection-&gt;prepare($command);
          $query-&gt;execute(array(":term"=&gt;"%{$term}%", ':lim'=&gt;$limit, ':col' =&gt; $column));
          print_r($query-&gt;fetchAll());
      }
  </code></pre>
  
  <p>and the return value is</p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5'' at line 1
  </code></pre>
  
  <p>From the duplicate, I changed the execute to this</p>
  
  <pre><code>$command = "SELECT name FROM `$table` WHERE ? LIKE ? LIMIT ?";
  
  ...
      $query-&gt;bindParam(1, $column,  PDO::PARAM_STR);
              $term = "%{$term}%";
              $query-&gt;bindParam(2, $term,  PDO::PARAM_STR);
              $query-&gt;bindParam(3, $limit,  PDO::PARAM_INT);
              $query-&gt;execute();
  </code></pre>
  
  <p>And now I am getting this:</p>
  
  <pre><code>Array ( )
  </code></pre>
  
  <p>Is my limit now 0 or something? What's going on?</p>