Date: 11/19/99
- Next message: Alexander Aulbach: "Re: [PHPLIB] count(*) on select"
- Previous message: Florian Gnägi: "Re: [PHPLIB] count(*) on select"
- In reply to: Marc Tardif: "[PHPLIB] count(*) on select"
- Next in thread: Chia-liang Kao: "Re: [PHPLIB] count(*) on select"
- Reply: Chia-liang Kao: "Re: [PHPLIB] count(*) on select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> How can I use count(*) and determine how many records are returned?
> I tried the following:
> $db->query("select count(*) from table where one='two'");
> if ($db->f("count")>0) $util->my_msg("no records");
>
> I also tried using nf() and num_rows(), but none seem to return the
> proper value of count(*). By the way, I'm using postgresql if that makes
> a difference.
>
count() is an aggregate, it will always return exactly ONE record. So $db-
>nf or Pg_Numrows are useless. You can use count OR $db->nf. Examples:
$db->query("select count(*) as numrecord from table where one='two'");
printf ("The number of record contained in table is: %d", $db-
>f("numrecord"));
And the other way is
$db->query("select * from table where one='two'");
printf ("The number of record contained in table is: %d", $db->nf());
they give exactly the same result. And both works under postgres, be
sure...
Hope this helps
bye!
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Fabrizio Ermini e-mail:
C.so Umberto, 7 f.ermini <email protected>
loc. Meleto Valdarno faermini <email protected>
52020 Cavriglia (AR) ICQ UIN: 24.64.37
ITALY
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.
- Next message: Alexander Aulbach: "Re: [PHPLIB] count(*) on select"
- Previous message: Florian Gnägi: "Re: [PHPLIB] count(*) on select"
- In reply to: Marc Tardif: "[PHPLIB] count(*) on select"
- Next in thread: Chia-liang Kao: "Re: [PHPLIB] count(*) on select"
- Reply: Chia-liang Kao: "Re: [PHPLIB] count(*) on select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

