|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2016-06-16 12:48 UTC] james at asgrim dot com
  [2016-06-16 16:25 UTC] james at asgrim dot com
  [2017-01-16 15:27 UTC] rangercairns@php.net
 
-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: rangercairns
  [2017-01-16 15:27 UTC] rangercairns@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 15:00:01 2025 UTC | 
Description: ------------ When executing exactly the same query, one non-prepared and one prepared, the prepared statement results in a VARCHAR filled with spaces the same length as the VARCHAR. For example, if we create a table with a single VARCHAR(32), and insert an empty string using a straight db2_exec, the value is correct. However, if we insert an empty string using db2_prepare and db2_bind_param, the resulting string is actually 32 whitespace characters. Test script: --------------- <?php $conn = db2_connect('<replace>', '<replace>', '<replace>', [ 'i5_naming' => DB2_I5_NAMING_OFF, 'i5_lib' => '<replace>', ]); db2_exec($conn, 'CREATE OR REPLACE TABLE FOO (BAR VARCHAR(32));'); db2_exec($conn, 'DELETE FROM FOO'); // Works fine db2_exec($conn, "INSERT INTO FOO VALUES ('')"); // Preparing and executing results in 32 space characters $stmt = db2_prepare($conn, 'INSERT INTO FOO VALUES (?)'); $value = ''; db2_bind_param($stmt, 1, "value", DB2_PARAM_IN); var_dump(db2_execute($stmt)); // Dump the results $r = db2_exec($conn, "SELECT * FROM FOO"); while ($row = db2_fetch_assoc($r)) { echo json_encode($row, JSON_PRETTY_PRINT) . "\n"; } Expected result: ---------------- bool(true) { "BAR": "" } { "BAR": "" } Actual result: -------------- bool(true) { "BAR": "" } { "BAR": " " }