|
Posted by FFMG on 07/26/07 06:14
Hi,
I was running a test on a table with 50000 rows.
When I do:
$sql = "SELECT * FROM TABLE";
$result = mysql_query($sql);
$total = mysql_num_rows(result);
I get a 'run out of memory error', (the limit is set low on the test
server).
But when I do:
$sql = "SELECT count(*) as num FROM TABLE";
$result = mysql_query($sql);
$result = mysql_fetch_assoc( $result );
$total = $result['num'];
Everything works fine.
or is
$sql = "SELECT FOUND_ROWS() AS num FROM TABLE";
...
even better?
So What is the 'preferred' method of getting a row count?
FFMG
--
'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=18782
Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).
Navigation:
[Reply to this message]
|