title: PDO Array to String Conversion - Parameter
body: <p>Pretty sure there's an easy fix for this, but I'm inexperienced in array handling when it comes to PDO statements</p>
  
  <p>Purpose: To retrieve a set of id's from the database, then use those ids to compare and retrieve </p>
  
  <pre><code>$SAList = getSecurityActionsForQuestion("$QID");
  $con = database::getInstance()-&gt;getConnection();
  $ParentList = $con-&gt;prepare('SELECT SQ.SurveyQuestionID, SQ.SurveyQuestionDesc 
  FROM SurveyQuestion SQ
  JOIN  SurveyQuestionLookup SQLP ON SQLP.SurveyQuestionID = SQ.SurveyQuestionID
  WHERE SQLP.SecurityActionID IN (:SAList)
     AND SQLP.SurveyQuestionID != :QID');
  $ParentList-&gt;bindValue(':QID',$QID, PDO::PARAM_STR);
  $ParentList-&gt;bindValue(':SAList',$SAList, PDO::PARAM_STR);
  $ParentList-&gt;execute();
  $Results = $ParentList-&gt;fetchAll();
  </code></pre>
  
  <p>Now, individually, both the 'getSecurityActionForQuestion' function and the inserted select statement work and retrieve what I want. The issue is that I cannot send an array into the PDO::PARAM_STR and I have not found a fix for this.</p>
  
  <p>I have seen some options to implode and prepare the string, but I'm not entirely sure how to incorporate this into my current design. </p>
  
  <p>There is a possibility of using a foreach loop that creates a new array, holds a count variable and then within the SQL statement, I could insert a bunch of named parameters, then use another for loop to bind each parameter to their respective places, but I'm pretty sure someone out there has a far more elegant process than that hackjob.</p>
  
  <p>EDIT:</p>
  
  <p>Addition of the getSecurityActionsForQuestion(ID) function for clarity</p>
  
  <pre><code>function getSecurityActionsForQuestion($QID)
  {
      $con = database::getInstance()-&gt;getConnection();
      $SAList = $con-&gt;prepare("SELECT DISTINCT SecurityActionID FROM SurveyQuestionLookup
      WHERE SurveyQuestionID = :QID");
      $SAList-&gt;bindValue(':QID',$QID,PDO::PARAM_INT);
      $SAList-&gt;execute();
      $Results = $SAList-&gt;fetchAll();
      $SAList=null;
      $con=null;  
      return $Results;
  }
  </code></pre>