title: Setting PDO/MySQL LIMIT with Named Placeholders
body: <p>I'm having an issue binding the <code>LIMIT</code> part of an SQL query. This is because the query is being passed as a string. I've seen <a href="https://stackoverflow.com/questions/2269840/php-pdo-bindvalue-in-limit">another Q</a> here that deals with binding parameters, nothing that deals with Named Placeholders in an array.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public function getLatestWork($numberOfSlides, $type = 0) {
  
  $params = array();
  $params["numberOfSlides"] = (int) trim($numberOfSlides);
  $params["type"] = $type;
  
  $STH = $this-&gt;_db-&gt;prepare("SELECT slideID 
      FROM slides
      WHERE visible = 'true'
          AND type = :type
      ORDER BY order
      LIMIT :numberOfSlides;");
  
  $STH-&gt;execute($params);
  
  $result = $STH-&gt;fetchAll(PDO::FETCH_COLUMN);
  
  return $result;        
  }
  </code></pre>
  
  <p>The error I'm getting is: <code>Syntax error or access violation near ''20''</code> (20 is the value of <code>$numberOfSlides</code>).</p>
  
  <p>How can I fix this?</p>