ID: 25777 Comment by: john dot g at envent dot co dot za Reported By: duh at dowebwedo dot com Status: Closed Bug Type: MSSQL related Operating System: Debian GNU/Linux 3.0 PHP Version: 4.3.4RC1 New Comment:
I agree with berni... besides, it's important for programmers to retrieve data from the database in the same format as they submit it. If I submit 'John' to a field called Name, I expect 'John' to be returned to me on request... not 'John '. I've managed to implement a simple workaround due to the fact that I use a DB abstraction layer, but others may not be as lucky. When can this be fixed? Previous Comments: ------------------------------------------------------------------------ [2004-06-03 14:04:49] berni at starsucker dot net As it is not very easy to revert these changes transparently in php, it would be nice to have a php.ini Setting to turn the trimming back on. Besides, I think it is very naive to try to get "the data as it is" from sql server. Microsofties are telling me that the DBLib is old and nobody with a brain uses it anymore: You can not tell a difference between varchar or char fields. You can not get more than 255 bytes from a var-* field. You have to convert the field to text, and it is not a problem to append something if you really want all the spaces: mssql_query ("SELECT convert(text, Field + '!')"); php_mssql.dll is not the place to get the data "as it is" because it is in no way compatible to COM-based Clients like ADO. It is also not compatible with FreeTDS by the way. The simple meaning is: Of course, PHP has to process the Output of DBLib / FreeTDS. As these 2 Libraries are behind the same extension, PHP should do even more processing on their output in order to make them compatible! What I really want to say: Introduce a new php.ini Setting for the trimming. Activate it by default. ------------------------------------------------------------------------ [2004-04-23 15:54:34] cbunk at arescorporation dot com The fix for this bug has caused a new bug. When querying a MSSQL db and the a field's value is empty a space gets returned, not an empty string as expected. This is causing lots off problems with scripts I have that check to see if a value is empty to determine if to display some stuff. The bug report http://bugs.php.net/bug.php?id=26996 got listed as bogus but it was a correct report. I'm not sure I think I may try submitting another bug report in hopes it will be noticed. ------------------------------------------------------------------------ [2004-03-30 06:22:35] arion_ at msn dot com Description: ------------ If a field is empty it returns one blank space character. Reproduce code: --------------- <?php $host="XXX"; $usuario="User"; $password="Password"; $bbdd="BBDD"; $conexion=mssql_connect("$host","$usuario","$password"); $qry="SELECT Field FROM dbo.Table"; $handle=mssql_query($qry); $registro=mssql_fetch_row($handle); $Nothing=$registro[0]; echo "A" .$Nothing. "B"; ?> Expected result: ---------------- AB Actual result: -------------- A B I reported this here http://bugs.php.net/bug.php?id=26996 and I have wait for the new release to solve this problem. I've just test with 4.3.5 and doesn't works yet. ------------------------------------------------------------------------ [2003-11-17 18:14:15] [EMAIL PROTECTED] The sybase and mssql extensions do not handle returned data the exact same way, and it might be that we need to readd the rtrim code to the sybase extensions. It seams like the dbconvert() finctions are implemented differently. You could also try the native mssql extension. That will work with FreeTDS as well, and give you more functions. ------------------------------------------------------------------------ [2003-11-17 17:29:18] cquincy at whitewave dot com I think I have run into a problem related to this bug fix. I am using sybase/freetds to interact with mssql on my company intranet like the orginator of this bug. Now with version 4.3.4 numbers, whether integer of floating points are coming back with spaces on the right side. i.e. you put "123" in the database, then when you mssql_fetch* you get back "123 ". Note that the originator of the bug was only concerned with char and varchar fields. 4.3.3 did not have this problem with numbers. So, it seems the "fix" has created an unforseen problem with numbers which is worse in my opinion than "hi " coming back as "hi". Obviously I expect to get exactly the same data that is stored in the database instead of right padded data. Expected result: ---------------- Put 123 in the database get back 123, not '123 '. Put 123.456 in the database get back 123.45, not '123.456 ' Thanks for your efforts. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/25777 -- Edit this bug report at http://bugs.php.net/?id=25777&edit=1