I have a really very simple request
select * from `users` where (`active` = 1 and `newsletter` = 1) and (`terminated` = 0 or (`terminated` = 1 and `newsletter_terminated` = 1));
I build it with an eloquent like this (the above query is output when I do it with toSql()
$recipients = User::where([ 'active' => 1, 'newsletter' => 1 ])->where(function ($query) { $query->where('terminated', 0) ->orWhere(function ($query){ $query->where('terminated', 1) ->where('newsletter_terminated', 1); }); })->get();
But when I execute this script, I get an error
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /xxx/eloquent/vendor/illuminate/database/Illuminate/Database/Connection.php on line 303
When I write specific columns in the get method, for example get(['id']); It works without problems. But I still don't understand why this is not working. There seems to be a memory leak, but where?
When I execute a query in my SQL client, the query ends in 3 ms, so it doesn't seem like too much data is happening. Unfortunately, I do not have xdebug on the installed firewall, so I cannot get stacktrace at the moment.
source share