Date: 11/19/99
- Next message: Chia-liang Kao: "Re: [PHPLIB] count(*) on select"
- Previous message: Fabrizio Ermini: "Re: [PHPLIB] count(*) on select"
- In reply to: Marc Tardif: "[PHPLIB] count(*) on select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 19 Nov 1999, Marc Tardif wrote:
}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.
Solutions:
$db->query("select count(*) as count from table where one='two'");
$db->next_record();
if ($db->Record[count]>0) $util->my_msg("no records");
Should also work, but depends on database:
$db->query("select count(*) from table where one='two'");
$db->next_record();
if ($db->Record[0]>0) $util->my_msg("no records");
--SSilk - Alexander Aulbach - Herbipolis/Frankonia Minoris - (0931)22032
- 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: Chia-liang Kao: "Re: [PHPLIB] count(*) on select"
- Previous message: Fabrizio Ermini: "Re: [PHPLIB] count(*) on select"
- In reply to: Marc Tardif: "[PHPLIB] count(*) on select"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

