Re: [PHPLIB] count(*) on select From: Alexander Aulbach (ssilk <email protected>)
Date: 11/19/99

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.