开发者

How do I count total of row in mysql without get Fatal error : Allowed memory

I got a problem Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 141954624 bytes) when to count all of row mysql table

$query = $db->query("SELECT * FROM table");
$count = $db->num_rows($query);

echo $count;

Total rows about 17k and I got Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 14195462开发者_如何转开发4 bytes). Let me know, how to fix it.


You could change your SQL query to...

SELECT COUNT(*) AS `rows_count` FROM `table`;

Then you don't have to load such a large recordset to just then use a row counting function to get the number of rows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜