title: Dynamic query with PDO and FIND_IN_SET
body: <p>I'm using PDO to build my queries which rely on FIND_IN_SET to select certain rows. The elements of the set are passed via POST to the server and the query constructed like this:</p>
  
  <pre><code>SELECT * FROM table WHERE
  (FIND_IN_SET('param1', column) &gt; 0 OR FIND_IN_SET('param2', column) &gt; 0)
  </code></pre>
  
  <p>That's, in a basic way, how the queries are constructed. Because the number of parameters to find in the set is dynamic, the FIND_IN_SET part of the query is made dynamically:</p>
  
  <pre><code>$q = implode("', column)&gt;0 OR FIND_IN_SET('", $array);
  </code></pre>
  
  <p>And then applied to the query, which looks like this:</p>
  
  <pre><code>SELECT * FROM table WHERE
  AND (FIND_IN_SET(:q, e.event_type)&gt;0);
  </code></pre>
  
  <p>And the query eventually executed as:</p>
  
  <pre><code>$countResult-&gt;execute(array(':q' =&gt; $q);
  </code></pre>
  
  <p>Note that $q may take the form of:</p>
  
  <pre><code>"param1', column)&gt;0 OR FIND_IN_SET('param2', column)&gt;0 OR FIND_IN_SET('param3"
  </code></pre>
  
  <p>If I don't use PDO, the query executes correctly, but when using PDO, the query works when there is only one element in the array, but doesn't return any results when the array contains more than one element.</p>
  
  <p>Is the execute method doing something to the parameter possibly?</p>