该表包含大约500,000条数据。
执行查询时,会出现如下所示的php使用错误。
“ PHP致命错误:耗尽了134217728字节的允许的内存大小(试图分配20480字节)”
什么是正确的解决方案?
MySQL代码
public function get_all($query)/*{{{*/
{
$result = [];
$tmp_row = mysql_query($query);
if($tmp_row != false)
{
while($row = mysql_fetch_assoc($tmp_row)) //PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
{
$result[] = $row;
}
}
else
{
$result = "SQL ERROR";
}
return $result;
}/*}}}*/
-更多详细信息
下面的查询使用“ get_all”功能。
SELECT id FROM 'test_Table' WHERE id = parent ORDER BY datetime DESC LIMIT 0, 40;
test_Table中有500,000条数据。
其中只有0-40位用户在选择数据。
您不需要导入总数为500,000的数据,按日期时间顺序只需导入0-40。