DOCTRINE PDO postgresql bindValue() with null -> SQLSTATE


DOCTRINE PDO postgresql bindValue() with null -> SQLSTATE[22P02]

我正在用PDO PostgreSQLPHP(+一些DOCTRINESYMFONY-但我不使用ORM)

在某个时刻,我有一个null值,我想在bindParam()函数中使用它。

它就像:

$sqlReadyToBindValue->bindValue(':an_integer_field',null,PDO::PARAM_INT);

我也尝试过:

$sqlReadyToBindValue->bindValue(':an_integer_field',null,PDO::PARAM_NULL);

在这两种情况下,它都会引发一个例外:

SQLSTATE[22P02]:无效的文本表示:7错误:在[SYMFONY FOLDER]''vendor''doctrine''dbal''lib''doctrine''dbal''Driver''AbstractPostgreSQLDriver.php第91行,整数"的输入语法无效

我没有得到它,因为我用bindValue()函数做的任何其他事情都会通过。

我注意到在阅读日志时,我的null在通过DOCTRINE时变成了两个简单的引号,类似于:

在DBALException::driverExceptionDuringQuery(对象(Driver),对象(PDOException),'SELECT an_integer_field FROM a_table WHERE an_integer_field = :an_integer_field', array(':an_integer_field' => ''))在供应商''条令''dbal''lib''条令''dbal''Statement.php中,第17行

然后:在AbstractPostgreSQLDriver->convertException('使用params["]执行'SELECT an_integer_field FROM a_table WHERE an_integer_field = :an_integer_field'时发生异常:SQLSTATE[22P02]:无效的文本表示形式:7错误:integer的无效输入语法:"',object(PDOException))在供应商''条令''dbal''lib''条令''dbal''DBALException.php中,第116行

然后它引发了我之前写过的第一个异常:AbstractPostgreSQLDriver.php行91(在屏幕上飞溅的那个)

有线索吗是否有办法确保null不会成为DOCTRINE中的引号

我在SQL查询中使用了"IS null"检查,而不是将参数绑定到它。