php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26828 queried bit fields are space-padded
Submitted: 2004-01-07 09:19 UTC Modified: 2004-01-09 09:13 UTC
From: jim dot hatfield at insignia dot com Assigned: iliaa (profile)
Status: Not a bug Package: Sybase (dblib) related
PHP Version: 4.3.4 OS: FreeBSD 4.5-RELEASE
Private report: No CVE-ID: None
 [2004-01-07 09:19 UTC] jim dot hatfield at insignia dot com
Description:
------------
Retrieve one row from a Sybase database using
DB-Lib and Freetds 0.61_1.

"manager" is a smallint and "ts_admin" is a "bit".
The first record has field values 1 and 0 for these
fields respectively.

I did a "portupgrade lang/php4" between the two runs so I know the only thing which changed was the PHP version.


Reproduce code:
---------------
$db = sybase_connect($server, $user, $pass);
sybase_select_db($dbname, $db);
res = 
$sybase_query("select manager, ts_admin from employees", $db)
$row = sybase_fetch_row($res);

echo "Manager  = \"$row[0]\"\n";
echo "TS_Admin = \"$row[1]\"\n";

Expected result:
----------------
4.3.3 returns:
Manager  = "1"
TS_Admin = "0"

Actual result:
--------------
4.3.4 returns:
Manager  = "1"
TS_Admin = "0                    "

note the space padding. When tested in 
an if this returns TRUE when without the
padding it is FALSE

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-07 21:27 UTC] sniper@php.net
See bug #25777 (assigning this to Ilia who removed this trimming from ext/sybase)



 [2004-01-09 08:50 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Not a bug. 
 
Read previous similar reports such as #26835, etc... 
 [2004-01-09 09:13 UTC] jim dot hatfield at insignia dot com
I have read #26835 and don't see how it is similar.
Also #26835 refers to VARCHAR types, whereas this is
for a BIT type.
 
I'm confused. How can padding a BIT with 19 spaces
be right? It means that in the example, if I say
if ($row[1])

then it always evaluates TRUE. I have to coerce to int
first to get the code to work. This is code which has been
working fine since mid-2002.
 [2004-01-29 04:45 UTC] asuter at vianetworks dot ch
hello,

I have the same problem with php 4.3.4 connecting to mssql 2000 from linux using dblib + freetds 0.61

all "bit" and "datetime" fields are padded with spaces when results are returned. previously I used php 4.2.3 which hadn't that problem.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 18:01:26 2019 UTC