I have a very weird problem and will be grateful for some help.
I have a complicated Laravel query with a WhereIn() with a big array in it. It worked fine for a very long time but now the array apparently got too big and the query returns with no result. If I try the exact same query (toSql() Laravel function) with the big array, it works fine and I have my result.
On my local server, it works fine with no problems no matter the size of the whereIn array but on Live is broken so I'm thinking about a PHP or MySql setting or something similar.
Do you have any idea?
The query is:
$boardgamesCats = \App\ProductCategory::query()
->select(['product_categories.id AS cat_id','product_categories.menu_name AS cat_name', DB::raw('COUNT(*) as products_count') ])
->join('product_product_category','product_categories.id', '=', 'product_product_category.productCategory_id')
->where('product_categories.status','=','active')
->where('product_categories.parent_id', '=','1')
->whereIn('product_product_category.product_id',$productIds)
->groupBy('product_categories.id')
->orderBy('ord')
->get();
The problem is that $productIds array. Currently, there are 2005 items (ids) in it. If I put 1500 ids in it, for example, it works and returns what I need.
CodePudding user response:
did you add ->get() at the end of your query ?
Example :
$users = DB::table('users')->get();
CodePudding user response:
The correct way is to edit your php.ini file. Edit memory_limit to your desire value.
memory_limit = 2000M
OR
you can add this line in first line of your function
ini_set('memory_limit', '-1');