php - 如果结果大则不显示结果

标签 php mysql laravel

这让我很头疼。已经 4 个小时了,我只是绕着它转:(。我的问题是当我从 mysql 获取大结果到 php 时它没有显示任何东西。总结果大约有 20000 多个数据。所以我所做的是限制结果为 1000,它确实按预期显示了结果。

是否需要设置或更改某些配置?

下面是我的示例查询

不起作用(当结果超过 10000 时)

select * from `tbl_item` where `pricelist_id` = 1 and `published` = 'unpublished' and `type` = 'item' and `parent_id` = 0 and `tbl_item`.`status` <> 'inactive' order by `order` asc limit 10000   

工作(只需将结果限制为 1000)

select * from `tbl_item` where `pricelist_id` = 1 and `published` = 'unpublished' and `type` = 'item' and `parent_id` = 0 and `tbl_item`.`status` <> 'inactive' order by `order` asc limit 1000

奇怪。帮助任何人。

问候,

最佳答案

也许结果集占用了太多内存。这会导致 fatal error ,您是否激活了 error_reporting?

ini_set('display_errors', 1);
error_reporting(-1);

您可以通过将此添加到您的脚本来设置更高的内存限制:

ini_set('memory_limit', '2048M'); // would be really high, but good enough to investigate on the problem

然后您可以使用memory_get_peak_usage() 来显示...嗯,内存消耗的峰值

关于php - 如果结果大则不显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37742433/

相关文章:

php - 如何向 Packagist 添加新的包版本?

php - 哪些 PDO 方法抛出异常?

PHP 正在删除在 echo 语句后键入的换行符

mysql - 在mysql查询中生成序列号

mysql - 优化sql查询-wordpress-sql_big_selects

PHP - 如何在带有 RT 索引的 Sphinx 中配置通配符和模糊搜索

mysql - 使用 MySQL Workbench 访问 Lightsail 实例的数据库

php - 强制点击提交按钮两次

php - 试图在laravel中获取非对象错误的属性

php - 使用现有数据库数据将不可空列添加到 laravel 迁移