我已经阅读了数十个报告此问题的问题,在所有这些问题中,最佳答案是“增加您的memory_limit
”。很公平,但这里我有一个 memory_limit=128M
并且我正在尝试检索两行,所以我猜查询中有错误。
这是LampsController@create
中的代码:
$families = DB::table('families AS f')
->join('products_families AS pf', 'pf.family_id', '=', 'f.id')
->join('products AS p', 'pf.product_id', '=', 'p.id')
->select(DB::raw('f.code'))
->where('p.category', '=', 'lamps');
// $families = Collection::unwrap($families);
print_r($families); exit;
数据库模式很简单:
A) 表族
----------------------------------------------
| id | code | name | created_at | updated_at |
| | | | | |
----------------------------------------------
B) 表 products_families
---------------------------------------------------------
| id | product_id | family_id | created_at | updated_at |
| | | | | |
---------------------------------------------------------
C) 表产品
-------------------------------------------
| id | category | created_at | updated_at |
| | | | |
-------------------------------------------
这是我得到的错误:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Allowed memory size of 134217728 bytes exhausted (tried to allocate 98570240 bytes)
我做错了什么?
最佳答案
添加get()
获取查询结果,如果要打印查询可以使用toSql()
关于php - Laravel:当 print_r 查询输出时允许的内存大小耗尽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49006940/