title: PDO: IF statement in query?
body: <p>I was wondering if it is possible to use something like a if statement in a PDO query.
  My current query is: </p>
  
  <pre><code>public static function UpdateTable( $id, $name, $variable )
  {
      self::query("
          UPDATE  table
          SET     name = :name,
          WHERE   id = :id
      ", array(
          ":name" =&gt; $name,
          ":id" =&gt; $id
      ));
  }
  </code></pre>
  
  <p>Which is prepared and executed by this:</p>
  
  <pre><code>public static function query($q, $params)
  {
      $stmt = self::$con-&gt;prepare( $q );
      $stmt-&gt;execute( $params );
  }
  </code></pre>
  
  <p>All of this works fine, but I also got the var $variable.
  And I want that database column to be updated if $variable is not empty.</p>
  
  <p>I can make a if / else statement in the "UpdateTable" function, but that quite ugly in my opinion en I couldn't find anything else on Google how to do this. So I would like to learn how to ;)</p>