title: PDO - Dynamic Query Building
body: <p>is it somehow possible to built a dynamic query for PDO?  </p>
  
  <p><strong>Description:</strong><br>
  I Have the following function:<br>
      function </p>
  
  <pre><code>saveContent($roundId,$answer,$question_de,$question_en,$files_1_1,$files_1_2,$files_2_1,$files_2_2,$files_3_1,$files_3_2) {
  
          $sql_pictures = "
              UPDATE ".DBPREFIX."pictures
              SET
                  file_1_static=:files_1_1,
                  file_1_animation=:files_1_2,
                  file_2_static=:files_2_1,
                  file_2_animation=:files_2_2,
                  file_3_static=:files_3_1,
                  file_3_animation=:files_3_2
              WHERE
                  roundId=:roundId";
          try {
              $db = self::getConnection();
              $stmt_pictures = $db-&gt;prepare($sql_pictures);
  
              $stmt_pictures-&gt;bindParam("roundId", $roundId);
              $stmt_pictures-&gt;bindParam("files_1_1", $$question_de);
              $stmt_pictures-&gt;bindParam("files_1_2", $question_en);
              $stmt_pictures-&gt;bindParam("files_2_1", $roundId);
              $stmt_pictures-&gt;bindParam("files_2_2", $$question_de);
              $stmt_pictures-&gt;bindParam("files_3_1", $question_en);
              $stmt_pictures-&gt;bindParam("files_3_2", $question_en);
  
              $stmt_pictures-&gt;execute();
              $db = null;
              return true;
          } catch(PDOException $e) {
              echo $e-&gt;getMessage();
          }
  
      }  
  </code></pre>
  
  <p>The important part is in "sql_pictures". I'm calling this function by passing the necessary data into the function, like this:  </p>
  
  <pre><code>if (isset($_POST['save'])) {        
              $saveContent = $helper-&gt;saveContent(
                  $_POST['roundId'],
                  $_POST['answer'],
                  $_POST['question_de'],
                  $_POST['question_en'],
                  $_FILES["files_1_1"],
                  $_FILES["files_1_2"],
                  $_FILES["files_2_1"],
                  $_FILES["files_2_2"],
                  $_FILES["files_3_1"],
                  $_FILES["files_3_2"]
              );  
          }
  </code></pre>
  
  <p>As some of you maybe notice, it's for a multiple file upload.<br>
  Now the main problem is, I don't want to update fields when either the string is empty (not set) or the value didn't changed (i.e $files_1_1 didn't changed or is empty).  </p>
  
  <p>How can I achieve that?  </p>
  
  <p><strong>Other question:</strong><br>
  Is it maybe better to use  </p>
  
  <pre><code>&lt;input type="file" name="files[]" id="file" /&gt;  
  </code></pre>
  
  <p>instead of  </p>
  
  <pre><code>&lt;input type="file" name="files_1_2" id="file" /&gt;
  </code></pre>
  
  <p>for each input field?<br>
  And how can I refactor the function then?  I'm sitting on it for many hours, but no clue. A hint would be nice! :)   </p>
  
  <p>Thanks!</p>