ID: 31641 Updated by: [EMAIL PROTECTED] Reported By: tomasz at biznespolska dot pl -Status: Assigned +Status: Bogus Bug Type: MSSQL related Operating System: win32 PHP Version: 4.3.10 Assigned To: iliaa New Comment:
As the original report explains, this is a bug in the interface library and not PHP. The old behaviour results in data mangling (space stripping). Previous Comments: ------------------------------------------------------------------------ [2005-01-22 15:05:02] [EMAIL PROTECTED] Ilia, you 'broke' it.. :) ------------------------------------------------------------------------ [2005-01-21 17:20:38] tomasz at biznespolska dot pl Ofcourse I mean "empty strings" not "empty spaces". Should be: "It is very rare that someone will store in database single space, but storing empty string is very common." ------------------------------------------------------------------------ [2005-01-21 17:12:44] tomasz at biznespolska dot pl Description: ------------ I'd like to continue thread: http://bugs.php.net/bug.php?id=25777 Because it's already closed I wasn't able to add my comments there. By disabling rtriming of text fields, new bug was introduced - empty strings are returned as single space. I know that is because of MS DBLib, but there is no problem to fix that in PHP. It is very rare that someone will store in database single space, but storing empty spaces is very common. So in my opinion most common usage should be considered. For example: if ( empty($text_from_db) ) { // do something } In my opinion ' ' should replaced by ''. I don't how to submit this to CVS, so I put it here: ext/mssql/mssql.c line 805: case SQLTEXT: { int length; char *data = charcol(offset); length=dbdatlen(mssql_ptr->link,offset); #if ilia_0 while (length>0 && data[length-1] == ' ') { /* nuke trailing whitespace */ length--; } #endif if ( length==1 && data[0]==' ' ) { /* single space to empty string */ length=0; } Z_STRVAL_P(result) = estrndup(data,length); Z_STRLEN_P(result) = length; Z_TYPE_P(result) = IS_STRING; break; } Reproduce code: --------------- //mssql_connect(...); var_dump(mssql_fetch_row(mssql_query("SELECT ''"))); Expected result: ---------------- array(1) { [0]=> string(0) "" } Actual result: -------------- array(1) { [0]=> string(1) " " } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31641&edit=1