RE: [PHP-DEV] PHP 4.0 Bug #4455: ifx_affected_rows() & ifx_num_rows() don't return correct numbers of rows. From: Andrej Falout (afalout <email protected>)
Date: 05/15/00

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> From: jfuertes <email protected>
> Operating system: Red Hat Linux 6.1
> PHP version: 4.0 Release Candidate 2
> PHP Bug Type: Misbehaving function
> Bug description: ifx_affected_rows() & ifx_num_rows() don't
> return correct numbers of rows.
>
> ifx_affected_rows() allways returns 1 even if a query result is
empty.

Because no rows are AFFECTED, and cannot be, with select. See Informix
manual for SQLCA record, and ifx_getsqlca() function.

> ifx_num_rows() allways returns 0 even if a query result got rows.

This function is often misunderstood, probably because it have name
similar to num_rows function in other PHP db interfaces that DO return
actual number of returned rows.

In short, returned number is SQL's engine optimizer's guess about the
number of rows to be returned. See same as above.

....snip....
 
If you are really interested in number of rows returned, you will need
to do SELECT COUNT(*) again with same where-part, or fetch row-by-row
and count them.

If you just want to see if row exists, do something like

$res_id = ifx_query($sql, $connid);
$row = ifx_fetch_row ($res_id, "FIRST");
if ( $row == FALSE) {$NOTFOUND=true;}else{$NOTFOUND=false;}

Yes, we probably need REAL ifx_num_rows() function.

This is not a bug. It may be a feature request. Should be closed.

Yours, Andrej Falout, http://www.falout.com ICQ 7628616
#-----------------------------------------------------------------
globals "std_disclaimer.4gl"

"Venus is still under construction. Thank you for your patience
and we apologize for the inconvenience." - Match.com online dating
site.
 
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.0.2i

iQA/AwUBOSABuRZH34ibpTRkEQINDQCgofZKYyor5kIOZnCx1p0URdINldIAoPeF
ZEcwk86PjD/RDtxKGrdQuENi
=2fLH
-----END PGP SIGNATURE-----

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>