Bind value with PDO, problems inserting IS NULL <p>I have this function: </p> <pre><code> function fetch_article_comments($article_id, $parent_id) { $app = new Connection(); if ($parent_id &gt; 0) { $parent_id = '= '. $parent_id; } else { $parent_id = "IS NULL"; } $sql = "SELECT * FROM recursive WHERE article_id = :article_id AND comment_parent :parent_id ORDER BY comment_timestamp DESC"; $query = $app-&gt;getConnection()-&gt;prepare($sql); try{ $query-&gt;execute(array(':article_id' =&gt; $article_id, ':parent_id' =&gt; $parent_id)); $comments = $query-&gt;fetchAll(); //returns an stdClass $query-&gt;closeCursor(); return $comments; } catch(PDOException $e){ die($e-&gt;getMessage()); } } </code></pre> <p>And i want <code>$parent_id</code> to be <code>IS NULL</code>. But i get this error message:</p> <blockquote> <p>PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''IS NULL' ORDER BY comment_timestamp DESC'</p> </blockquote> <p>And for the sake of nice clean code, i don't want the whole query inside the if statement.</p> <p>But how can <code>$parent_id</code> be set to <code>IS NULL</code> and not <code>'IS NULL'</code>?</p>