From: arobins at csg dot uwaterloo dot ca Operating system: Win2k or Linux PHP version: Irrelevant PHP Bug Type: ODBC related Bug description: ODBC Column Name Truncation
Description: ------------ When retrieving ODBC results from Sybase SQL Anywhere 6 and 9, the column names are being truncated to 31 characters. This happens even if the column name is simply specified using sql 'AS' (i.e. "select column as a_really_long_name_that_is_longer_than_31_characters from crap" would still return "a_really_long_name_that_is_long" as the column name). Have tried in PHP 4 and 5, Win2K Server and SUSE Linux, all with same results. -- The buffer used by the odbc extension to store field names is only 32 bytes. Reproduce code: --------------- <?php $DBN = 'thedbn'; $UID = 'theuid'; $PWD = 'thepws'; $CONN = odbc_connect( $DBN, $UID, $PWD ) or die( "Cannot connect to $DBN."); $sql = "select * from crap"; $result = odbc_exec( $CONN, $sql ); for( $i = 1 ; $i <= odbc_num_fields( $result ) ; $i++ ) { $name = odbc_field_name( $result, $i ); ${$name} = odbc_result( $result, $name ); print( "$i: $name - ${$name}\n" ); } ?> Expected result: ---------------- 1: key - 4 2: a_really_long_name_that_is_longer_than_31_characters - 5 3: longer_name - 6 Actual result: -------------- 1: key - 4 2: a_really_long_name_that_is_long - 5 3: longer_name - 6 -- Edit bug report at http://bugs.php.net/?id=30043&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30043&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30043&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30043&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30043&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30043&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30043&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30043&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30043&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30043&r=support Expected behavior: http://bugs.php.net/fix.php?id=30043&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30043&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30043&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30043&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30043&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30043&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30043&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30043&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30043&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30043&r=mysqlcfg