Bug #16923 Updated: mysql_fetch_object returning incomplete data

2002-05-01 Thread mark

 ID:   16923
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Open
 Bug Type: MySQL related
 Operating System: slackware 8.0 (modified)
 PHP Version:  4.2.0
 New Comment:

I finally tracked this down... it was a bad sql call on my 
part (sort of) and a change in behaviour in 
mysql_fetch_object

I did a call like select * from products left join details 
on products.prodId=details.prodId

which returns 2 different prodId (one from each 
table)because of the join and the fact the details 
doesn't always include prodId (i.e. if there is not a 
matching join) the second prodId was NULL

in php 4.0.4pl1 mysql_fetch_object still set a valid prodId 
for everything ( I am assuming it ignored the NULL 
value)...in php 4.0.6 and newer it sets it to the last 
value it got for prodId (again assuming) which is sometimes 
NULL, sometimes a good value

not sure whether this should be a bug or not.  Anyone?

Mark


Previous Comments:


[2002-04-30 01:28:59] [EMAIL PROTECTED]

This was found in an ongoing project I am upgrading from php 4.0.4pl1

code sample:

$sql='select prodId, prodNum from products';
$result = mysql_query($sql);

do {
print_r($product);
print $product-prodId . . $product-prodNum
} while ($product = mysql_fetch_object($result));

print_r ($product) returns:
stdClass Object ( [prodId] = [prodNum] = E-U-00-002)
stdClass Object ( [prodId] = [prodNum] = E-U-00-003)
stdClass Object ( [prodId] = [prodNum] = E-U-00-004)

the real data would be prodId = 1, prodId = 2

the same thing done with mysql_fetch_array works perfectly (exact same
sql, etc) 

I tried various loops (do..while, if, while) no changes.

Tested this with php 4.1.2 and 4.2.0 w/ same errors.  Works fine on
4.0.4pl1.

php configure options as follows:

'./configure' \
'--with-mysql=/usr/local' \
'--enable-track-vars' \
'--with-dbase' \
'--with-gd=/usr/local/gd-1.8.4' \
'--with-ttf' \
'--with-t1lib' \
'--with-jpeg-dir' \
'--with-png-dir' \
'--with-tiff-dir' \
'--with-apxs=/usr/local/apache/bin/apxs' \
'--with-config-file-path=/usr/local/apache/conf' \
'--with-pdflib' \
'--enable-ftp' \
'--with-zlib-dir' 

I am unable to provide a backtrace (production server, sorry)





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




Bug #16923 Updated: mysql_fetch_object returning incomplete data

2002-05-01 Thread mark

 ID:   16923
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
-Status:   Open
+Status:   Bogus
 Bug Type: MySQL related
 Operating System: slackware 8.0 (modified)
 PHP Version:  4.2.0
 New Comment:

Can someone check to see if this needs attention or not?


Previous Comments:


[2002-05-01 17:21:05] [EMAIL PROTECTED]

I finally tracked this down... it was a bad sql call on my 
part (sort of) and a change in behaviour in 
mysql_fetch_object

I did a call like select * from products left join details 
on products.prodId=details.prodId

which returns 2 different prodId (one from each 
table)because of the join and the fact the details 
doesn't always include prodId (i.e. if there is not a 
matching join) the second prodId was NULL

in php 4.0.4pl1 mysql_fetch_object still set a valid prodId 
for everything ( I am assuming it ignored the NULL 
value)...in php 4.0.6 and newer it sets it to the last 
value it got for prodId (again assuming) which is sometimes 
NULL, sometimes a good value

not sure whether this should be a bug or not.  Anyone?

Mark



[2002-04-30 01:28:59] [EMAIL PROTECTED]

This was found in an ongoing project I am upgrading from php 4.0.4pl1

code sample:

$sql='select prodId, prodNum from products';
$result = mysql_query($sql);

do {
print_r($product);
print $product-prodId . . $product-prodNum
} while ($product = mysql_fetch_object($result));

print_r ($product) returns:
stdClass Object ( [prodId] = [prodNum] = E-U-00-002)
stdClass Object ( [prodId] = [prodNum] = E-U-00-003)
stdClass Object ( [prodId] = [prodNum] = E-U-00-004)

the real data would be prodId = 1, prodId = 2

the same thing done with mysql_fetch_array works perfectly (exact same
sql, etc) 

I tried various loops (do..while, if, while) no changes.

Tested this with php 4.1.2 and 4.2.0 w/ same errors.  Works fine on
4.0.4pl1.

php configure options as follows:

'./configure' \
'--with-mysql=/usr/local' \
'--enable-track-vars' \
'--with-dbase' \
'--with-gd=/usr/local/gd-1.8.4' \
'--with-ttf' \
'--with-t1lib' \
'--with-jpeg-dir' \
'--with-png-dir' \
'--with-tiff-dir' \
'--with-apxs=/usr/local/apache/bin/apxs' \
'--with-config-file-path=/usr/local/apache/conf' \
'--with-pdflib' \
'--enable-ftp' \
'--with-zlib-dir' 

I am unable to provide a backtrace (production server, sorry)





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