I've read tens of questions reporting this problem and in all of them the best answer was "increase your memory_limit". Fair enough, but here I have a memory_limit=128M and I'm trying to retrieve two lines, so I guess there's an error in the query.
This is the code in 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;
The database schema is simple:
A) table families
----------------------------------------------
| id | code | name | created_at | updated_at |
| | | | | |
----------------------------------------------
B) table products_families
---------------------------------------------------------
| id | product_id | family_id | created_at | updated_at |
| | | | | |
---------------------------------------------------------
C) table products
-------------------------------------------
| id | category | created_at | updated_at |
| | | | |
-------------------------------------------
And this is the error I get:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Allowed memory size of 134217728 bytes exhausted (tried to allocate 98570240 bytes)
What am I doing wrong?
DB::raw('f.code')? Can you try with just simply'f.code'?get()to get the result, you can dodd()or if you want to print you can usetoSql()DB::raw()because firstly I had in mind another queryget(). Shame on me. Thank you Ganesh