php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59744 SQL returning half of CCSID 37 column content
Submitted: 2011-05-03 10:50 UTC Modified: 2018-08-27 09:39 UTC
From: jim at ouac dot on dot ca Assigned: vnkbabu (profile)
Status: Closed Package: ibm_db2 (PECL)
PHP Version: 5.3.5 OS: Linux
Private report: No CVE-ID: None
 [2011-05-03 10:50 UTC] jim at ouac dot on dot ca
Description:
------------
Our database backend server is on IBM i.  Frontend server is 
Redhat with DB2 Connect installed.  The database table uses 
CCSID 37. When we use DB2 connect CLI at command line, the 
SQL runs just fine, returning 30 "?".  But when running the 
same SQL in PHP, PHP returns half of the column content - 
only 15 "?".

It would appear that php ibm_db2 module has trouble 
interpreting the length of the column or presenting the 
results.

--------------------
[db2inst1@dzendsvr ~]$ db2 "select givenm from webapp.rrootp 
where rrshnbr=2335272"

GIVENM
------------------------------
??????????????????????????????

  1 record(s) selected.

[db2inst1@dzendsvr ~]$ echo $LANG
en_US.UTF-8
[db2inst1@dzendsvr ~]$ /usr/local/zend/bin/php  
/var/www/test/jimproject/public/jimtest.php
Connection to database succeeded.???????????????
[db2inst1@dzendsvr ~]$ db2set
DB2COMM=tcpip
DB2CODEPAGE=1208
[db2inst1@dzendsvr ~]$ db2 "select 
substr(column_name,1,20),data_type,ccsid from 
qsys2.syscolumns where table_schema='WEBAPP' and 
table_name='RROOTP'"

00001                DATA_TYPE CCSID
-------------------- --------- -----------
RRSHNBR              INTEGER             -
TREFNO               CHAR               37
TITLE                CHAR               37
SURNAM               CHAR               37
GIVENM               CHAR               37
PRENAM               CHAR               37

[root@dzendsvr public]# yum info php-5.3-ibmdb2-zend-
server.i386
Loaded plugins: rhnplugin, security
Installed Packages
Name       : php-5.3-ibmdb2-zend-server
Arch       : i386
Version    : 5.3.5
Release    : 11
Size       : 63 k
Repo       : installed
Summary    : PHP ibmdb2 extension.
URL        : http://www.php.net
License    : The PHP License v3.01
Description: PHP ibmdb2 extension.

[root@dzendsvr public]# yum provides /usr/local/zend/bin/php
Loaded plugins: rhnplugin, security
php-5.3-dev-zend-server-5.3.5-28.i386 : ZendServer's 
development package
Repo        : Zend
Matched from:
Filename    : /usr/local/zend/bin/php

[root@dzendsvr public]# yum info php-5.3-ibmdb2-zend-
server.i386
Loaded plugins: rhnplugin, security
Installed Packages
Name       : php-5.3-ibmdb2-zend-server
Arch       : i386
Version    : 5.3.5
Release    : 11
Size       : 63 k
Repo       : installed
Summary    : PHP ibmdb2 extension.
URL        : http://www.php.net
License    : The PHP License v3.01
Description: PHP ibmdb2 extension.




Reproduce code:
---------------
[root@dzendsvr public]# cat /var/www/test/jimproject/public/jimtest.php
<?php
$db_name  = 'DRDA_DB';
$usr_name = 'user';
$password = 'xxxxxx';
$conn_resource = db2_connect($db_name, $usr_name, $password);
if ($conn_resource) {
    echo 'Connection to database succeeded.';
} else {
    echo 'Connection to database failed.<br />';
    echo 'SQLSTATE: ' . db2_conn_error() . '<br />';
    echo 'Message: '  . db2_conn_errormsg(). '<br />';
}

# $sql = 'SELECT * from jim.test';
$sql = 'select givenm from webapp.rrootp where rrshnbr = 2335272';
$stmt = db2_exec($conn_resource,$sql,array('cursor' => DB2_SCROLLABLE));
while ($row = db2_fetch_array($stmt)) {
     print "$row[0]\n";
}

db2_close($conn_resource);
?>

Expected result:
----------------
[db2inst1@dzendsvr ~]$ /usr/local/zend/bin/php  
/var/www/test/jimproject/public/jimtest.php
Connection to database 
succeeded.??????????????????????????????

Note: We expect to see thirty ?, as CLI returns. 


Actual result:
--------------
[db2inst1@dzendsvr ~]$ /usr/local/zend/bin/php  
/var/www/test/jimproject/public/jimtest.php
Connection to database succeeded.???????????????

Note: We only see fifteen ?. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-04 01:34 UTC] abhargav at in dot ibm dot com
Hi,

The characters that you are inserting into the table are double byte chars ("?" is a double byte char). To handle these unicode characters, we need to have unicode support in IBM_DB2 extension (Which is not there as of now).

I suggest you to use VARGRAPHIC data type instead of CHAR/VARCHAR, if you are going to store unicode data in it.

Regards,
Ambrish Bhargava
 [2011-05-11 15:28 UTC] jim at ouac dot on dot ca
Thanks very much Ambrish.  

> we need to have unicode support in IBM_DB2 extension (Which 
is not there as of now).

Do you have a rough estimate as to when unicode support will 
be released to public.
 [2018-08-27 09:39 UTC] vnkbabu@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vnkbabu
 [2018-08-27 09:39 UTC] vnkbabu@php.net
As this issue is very old, Closing it.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jan 26 14:01:24 2020 UTC