|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2013-12-24 10:35 UTC] josemalonsom at yahoo dot es
 Description:
------------
The PDO Informix driver trims trailing spaces on varchar and lvarchar types.
CSDK: 4.10UC2DE
PHP: 5.3.10, 5.5.7
PDO_INFORMIX: 1.2.7, 1.3.1
Informix: IDS 11.50.UC9DE
Test script:
---------------
  $con = new PDO($dsn, $user, $passwd);
  $sql = 'create table test_varchar (test_varchar varchar(10),test_lvarchar lvarchar(10))';
  $con->exec($sql);
  $sql = 'insert into test_varchar(test_varchar, test_lvarchar) values ("foo ", "foo ")';
  $con->exec($sql);
  $sql = 'select * from test_varchar';
  $row = $con->query($sql)->fetch(PDO::FETCH_ASSOC);
  print strlen($row['TEST_VARCHAR']) . "\n";
  print strlen($row['TEST_LVARCHAR']) . "\n";
Expected result:
----------------
The fetched strings had to be the same that the inserted strings.
Actual result:
--------------
The trailing spaces of the strings are removed (the spaces are saved in the database, it can be checked with the dbaccess command).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 05:00:02 2025 UTC | 
I did the debug of PDO_INFORMIX, i printed the fetched values right after issuing the SQLFetchScroll() API, i can see we are getting the trimmed down string from the informix ODBC driver. (gdb) 1029 rc = SQLFetchScroll((SQLHSTMT)stmt_res->hstmt, direction, (SQLINTEGER) offset); (gdb) p stmt_res->columns[0] $8 = {name = 0x7ffff6271eb0, namelen = 12, data_type = 12, returned_type = PDO_PARAM_STR, data_size = 10, nullable = 1, scale = 0, out_length = 3, data = {l_val = 140737323217184, str_val = 0x7ffff6283120 "foo"}} (gdb) p stmt_res->columns[1] $9 = {name = 0x7ffff6271f00, namelen = 13, data_type = 12, returned_type = PDO_PARAM_STR, data_size = 10, nullable = 1, scale = 0, out_length = 3, data = {l_val = 140737323217232, str_val = 0x7ffff6283150 "foo"}} I also see the similar discussion with ODBC application, https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014438618 If you disagree please raise an PMR to Informix Client team.