ID:               33060
 User updated by:  phpbugs at mfoxx dot myspamkiller dot com
 Reported By:      phpbugs at mfoxx dot myspamkiller dot com
 Status:           Bogus
 Bug Type:         MSSQL related
 Operating System: winxp, sp1
 PHP Version:      5.0.4
 New Comment:

Fair enough... I spent about 3 hours today searching online trying to
find out if anyone had documented this... I just didn't find/recognize
this comment on the php.net page, so I apologize for the bogus bug
report.

Although, I WOULD say, this IS a bug... just not a PHP bug really.  Why
in the heck hasn't someone updated that library since SQL Server 6.x
(circa 1998)?????  That is just a bit damn ridiculous.


Previous Comments:
------------------------------------------------------------------------

[2005-05-18 23:03:47] [EMAIL PROTECTED]

"Note: In Windows, the DBLIB from Microsoft is used. Functions that
return a column name are based on the dbcolname() function in DBLIB.
DBLIB was developed for SQL Server 6.x where the max identifier length
is 30. For this reason, the maximum column length is 30 characters. On
platforms where FreeTDS is used (Linux), this is not a problem".
http://www.php.net/mssql

------------------------------------------------------------------------

[2005-05-18 22:51:15] phpbugs at mfoxx dot myspamkiller dot com

Description:
------------
FYI:  I am running php 5.0.4 (binary distro) for windows, with apache
2.0.50 (binary distro), on a winXP sp1 machine.

If i execute:

select field1 as 'abcdefghijklmnopqrstuvwxyz0123456789' from mytable

in SQL Query Analyzer against a SQL Server 2000 database, i get the
expected result that the field name is named that whole big long alias,
36 characters in length.  

However, when i execute the same query using mssql_query() in PHP, and
i examine the results of mssql_fetch_object(), mssql_fetch_array(), or
mssql_fetch_assoc(), the field name (alias) is truncated at 30
characters (it seems).

I do the same test against the mysql_xxx extension, and I get no
truncation (i tested with upwards of about 100 chars in the field_name
alias and all was fine).

Reproduce code:
---------------
$link = mssql_connect("localhost","sa","mypassword");
mssql_select_db("my_db",$link);

$query = "select field1 as 'abcdefghijklmnopqrstuvwxyz0123456789' from
my_table";

$result = mssql_query($query);
print_r(mssql_fetch_object($result));

$result = mssql_query($query);
print_r(mssql_fetch_array($result));

$result = mssql_query($query);
print_r(mssql_fetch_assoc($result));

Expected result:
----------------
stdClass Object ( [abcdefghijklmnopqrstuvwxyz0123456789] => 0 ) Array (
[0] => 0 [abcdefghijklmnopqrstuvwxyz0123456789] => 0 ) Array (
[abcdefghijklmnopqrstuvwxyz0123456789] => 0 )

Actual result:
--------------
stdClass Object ( [abcdefghijklmnopqrstuvwxyz0123] => 0 ) Array ( [0]
=> 0 [abcdefghijklmnopqrstuvwxyz0123] => 0 ) Array (
[abcdefghijklmnopqrstuvwxyz0123] => 0 )


** notice that all 3 methods have a truncated field_name to 30
characters.  This obviously results in unexpected code problems when I
have dynamic SQL queries being generated and its difficult to predict
if an alias I assign to a field may exceed this limit, and if it does,
i never get the value out in my result-set processing because the name
doesn't match what i think it should.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33060&edit=1

Reply via email to