Bug #72028 [Com]: pg_query_params(): NULL converts to empty string

From: Date: Fri, 15 Jul 2016 09:01:35 +0000
Subject: Bug #72028 [Com]: pg_query_params(): NULL converts to empty string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202345@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72028&edit=1 ID: 72028 Comment by: ravisen at mail dot ru Reported by: iivarih at gmail dot com Summary: pg_query_params(): NULL converts to empty string Status: Closed Type: Bug Package: PostgreSQL related Operating System: Debian Jessie PHP Version: 7.0.5 Block user comment: N Private report: N New Comment: The problem has not been solved so far. Repeats on the version of PHP Version 7.0.8-4 Previous Comments: ------------------------------------------------------------------------ [2016-04-16 04:30:33] laruence@php.net Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=7e01c518b6a504846f397b787ab285105531d562 Log: Fixed bug #72028 (pg_query_params(): NULL converts to empty string) ------------------------------------------------------------------------ [2016-04-16 04:30:07] laruence@php.net Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=7e01c518b6a504846f397b787ab285105531d562 Log: Fixed bug #72028 (pg_query_params(): NULL converts to empty string) ------------------------------------------------------------------------ [2016-04-15 09:25:06] iivarih at gmail dot com Description: ------------ pg_query_params(): NULL converts to empty string, but only after looping over the params array with a reference. php version: 7.0.5-1~dotdeb+8.1 tested against postgres 9.5 Test script: --------------- $sql = "INSERT INTO params_test (value, details) VALUES ($1, $2)"; $params = array(null, "insert before looping with a reference"); $result = pg_query_params($this->connection, $sql, $params); $params2 = array(null, "insert after looping with a reference"); foreach ($params2 as &$p) { // doing nothing } unset($p); $result = pg_query_params($this->connection, $sql, $params2); Expected result: ---------------- I would expect that both calls to pg_query_params() would insert SQL NULL as 'value'. Actual result: -------------- The first call to pg_query_params() inserts SQL NULL as expected: 2016-04-15 11:59:07 EEST LOG: execute <unnamed>: INSERT INTO params_test (value, details) VALUES ($1, $2) 2016-04-15 11:59:07 EEST DETAIL: parameters: $1 = NULL, $2 = 'insert before looping with a reference' The second call inserts empty string as 'value' which is unexpected: 2016-04-15 11:59:07 EEST LOG: execute <unnamed>: INSERT INTO params_test (value, details) VALUES ($1, $2) 2016-04-15 11:59:07 EEST DETAIL: parameters: $1 = '', $2 = 'insert after looping with a reference' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72028&edit=1

« previous php.bugs (#202345) next »