Edit report at https://bugs.php.net/bug.php?id=54026&edit=1
ID: 54026 Updated by: yohg...@php.net Reported by: abrahala at gmail dot com Summary: PostgreSQL: cannot bind NULL value to statement condition -Status: Open +Status: Feedback Type: Bug Package: PDO related Operating System: Debian GNU/Linux 2.6.26-2-amd64 PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Did last comment work for you? Previous Comments: ------------------------------------------------------------------------ [2011-07-30 23:36:09] dverite at gmail dot com You should write "...WHERE :nullValue IS NULL" instead of ".. WHERE NULL IS :nullValue", otherwise execute() fails with a syntax error. I'm not sure your example would work anyway since passing a null value in a bind parameter seems problematic, but at least it would fail because of PDO and not because of the SQL itself :) ------------------------------------------------------------------------ [2011-02-15 15:28:42] abrahala at gmail dot com Sorry, I forgot to mention this only applies to binding a null value as part of a condition. Value assignment works fine (fieldName = :nullValue), so it might has to do something with the 'IS' keryword? ------------------------------------------------------------------------ [2011-02-15 14:59:36] abrahala at gmail dot com Description: ------------ It seems to be impossible to pass NULL value to a PDO PostgreSQL statement neither with bindValue nor using '?'-format and $statement->execute(array(null)). Test script: --------------- $pdo = new PDO('pgsql:host=localhost;port=5432;dbname=db', 'user', 'pass'); $statement = $pdo->prepare('SELECT \'ok\' WHERE NULL IS :nullValue'); $statement->bindValue(':nullValue', null, PDO::PARAM_NULL); $statement->execute(); $result = $statement->fetchColumn(0); var_export($result); Expected result: ---------------- 'ok' Actual result: -------------- false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54026&edit=1