|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 ?. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
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