PHP applications that use the iSeries Access for Linux ODBC driver to SELECT CHAR data containing characters outside the invariant character set (for example: ""), and using a UTF-8 locale, may receive extra garbage data at the end of the character string. This is caused by PHP passing an insufficient target length on the call to SQLBindCol(). PHP is setting the incorrect buffer length by using SQLColAttributes to return the SQL_COLUMN_DISPLAY_SIZE.
PHP Bug 47133: php-odbc SQLBindCol() not used correctly has been submitted.
IBM Support has seen this behavior in PHP versions 5.1 and 5.2.6-2. This problem also exists in PHP for Windows. iSeries Access for Linux versions 5.4 and 6.1 is affected.
The ODBC driver correctly returns error message CWB0111 - A buffer passed to a system call is too small to hold return data .
The ODBC driver has implemented a circumvention to not return the extra garbage data at the end of the CHAR string when using a connection string keyword option. PHP applications could then ignore the CWB0111 error message.
Developers of PHP applications that wish to use this work-around and prevent the extra garbage data must pass in the following connection string keyword:
DEBUG = 65536
The above line in bold can be added to an ODBC DSN in an odbc.ini file.
Versions of the iSeries Access for Linux ODBC driver that contain the circumvention are available here:
o PHP does not calculate all buffer lengths using SQL_COLUMN_DISPLAY SIZE, so PHP developers could use other SQL column types such as:
SQL_BINARY, SQL_VARBINARY, SQL_LONGVARBINARY or SQL_LONGVARCHAR. No binding occurs with those data types and SQLGetData() is used to retrieve the value.
o For long data, it may be necessary to call PHP ODBC API odbc_longread() (//us3.php.net/odbc_longreadlen ) because that is the length to be used for the buffer. If less data is available, PHP shrinks the buffer; however, if more data is available, truncation will occur.
APAR SE33393 describes this defect as encountered using PHP for Windows.
System i Support
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.