|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-04-16 04:30 UTC] laruence@php.net
[2016-04-16 04:30 UTC] laruence@php.net
-Status: Open
+Status: Closed
[2016-04-16 04:30 UTC] laruence@php.net
[2016-07-15 09:01 UTC] ravisen at mail dot ru
[2016-07-20 11:32 UTC] davey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 20:00:01 2025 UTC |
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'