RE: Re: Li'l problem with count()

2006-03-28 Thread Jay Blanchard
[snip] I think that the fastest method and the cheapest one is using "select count(*) from table" and using mysql_num_rows(), isn't it ? but there realy is no other way of retrieving the count() directly, without passing by the php function ? [/snip] Actually, SELECT COUNT only returns one row,

Re: Li'l problem with count()

2006-03-28 Thread Sandy
Hi Jay I just tried your code but I used $foo=mysql_fetch_object($result) and returned $foo->flyCount. It works the same as your code. (I actually have 738 flies in my pot, it's a crowd, and a lot of proteins !!! ;-) ). What method is heavier on the MySQL engine ? count() is said to be the f

Re: Li'l problem with count()

2006-03-28 Thread Sandy
thanks Because $result is a resource in PHP, not the actual result of the query; $foo = mysql_num_rows($result); -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: Li'l problem with count()

2006-03-28 Thread Peter Brawley
Sandy, >$result = mysql_query($sql,$lnk); >... >Why this leads to 'ressource id #10' instead of the flies count ? >The query gives the actual count if I use it in a line command !! You've been fooled by your variable name. For SELECT, SHOW, DESCRIBE or EXPLAIN, mysql_query() returns a resource

RE: Li'l problem with count()

2006-03-28 Thread Jay Blanchard
[snip] Flies in pot = function flies(){ $sql = 'select count(*) from flies'; $lnk = mysql_connect('localhost','root','123456'); $db = mysql_select_db('moar',$lnk); $result = mysql_query($sql,$lnk); mysql_free_result($result); mysql_close($lnk); return $result; } Why this leads to 'resource id #

Li'l problem with count()

2006-03-28 Thread Sandy
Hi Flies in pot = function flies(){ $sql = 'select count(*) from flies'; $lnk = mysql_connect('localhost','root','123456'); $db = mysql_select_db('moar',$lnk); $result = mysql_query($sql,$lnk); mysql_free_result($result); mysql_close($lnk); return $result; } Why this leads to 'ressource id