ID:               25777
 Comment by:       jfitz at gmx dot net
 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:

Why has this bug been closed?  The fact that the error lies in the
underlying MS library is inconsequential - the bug still actively
affects PHP developers and should be tracked whilst the solution is a
'work-in-progress'.


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

[2004-06-25 00:13:31] [EMAIL PROTECTED]

Inserting 'john ' into a char(10) filed should return 'john      ' (6
spaces) as the filed is a fixed length column. PHP should return the
value that way and that's how it works now. The database allows the
user to insert a value that is shorter than the required length.

The problem is with empty char or varchar values. The DB library used
to build the extension on returns the same value for '' (empty) and ' '
(one space). Fixing it and not fixing it is both wrong. The only real
fix is to get a version of DBLIB that does not have this bug. That part
is in the works with the help of FreeTDS on win32.

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

[2004-06-24 23:54:31] john dot g at envent dot co dot za

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?

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

[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.

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

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

Reply via email to