0

When using the PDO ASSOC statement I am only getting first letter of the column instead of the full one. Any ideas ? More information below :

Small code block to fetch_assoc via PHP :

$pdo = new PDO("xxx", "user","pwd");
$pdo->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_TO_STRING);
$query = $pdo->query("SELECT TRND.TRANID FROM PCRMTRND AS TRND");
$query->execute();
$tmp = array();
while($row=$query->fetch(PDO::FETCH_ASSOC)) {
        array_push($tmp,$row);
}

After filling array tmp :

enter image description here

Var DUMP each row :

enter image description here

Settings of ODBC :

[xxx]
Description             = iSeries ODBC
Driver                  = IBM i Access ODBC Driver
System                  = /
UserID                  = 
Password                = 
Naming                  = 0
DefaultLibraries        = QGPL
Database                =
ConnectionType          = 0
CommitMode              = 2
ExtendedDynamic         = 1
DefaultPkgLibrary       = QGPL
DefaultPackage          = A/DEFAULT(IBM),2,0,1,0,512
AllowDataCompression    = 1
LibraryView             = 0
AllowUnsupportedChar    = 0
ForceTranslation        = 0
Trace                   = 0
David
  • 840
  • 6
  • 17
  • 37
  • Why you're adding the result into array instead of echoing it out? Are you sure your code is intended to test the behavior you described? – Your Common Sense May 11 '16 at 13:06
  • Yes . I just add to have all the results in one array. I can see it in debug that array only has one key letters – David May 11 '16 at 13:16
  • Unfortunately, we can't see it. In order to get help, you need to provide the code you are using and the actual output you have – Your Common Sense May 11 '16 at 13:21
  • I've edited the post a little more but I guess it's a configuration option in PHP INI or settings in the ODBC. – David May 11 '16 at 13:57
  • What is that this picture? Can't you do just `$row=$query->fetch(PDO::FETCH_ASSOC); var_dump($row);` and check the output? – Your Common Sense May 11 '16 at 13:59
  • Thats a debug window from netbeans. I've also added a var_dump picture. – David May 11 '16 at 14:03

1 Answers1

1

I encountered the same issue, it seems it has something to do with locale settings. When I changed LC_ALL from "en_US.UTF-8" to "en_US.ISO-8859-1" the problem disappeared. Hence I don't have the output in UTF :(