Answer the question
In order to leave comments, you need to log in
Laravel difference where?
What's the difference between
#
->where(function($query) {
$query->where('url', 'like', '%facebook.com%');
$query->orwhere('url', 'like', '%twitter.com%');
$query->orWhere('url', 'like', '%instagram.com%');
})
->where('url', 'like', '%facebook.com%')
->orwhere('url', 'like', '%twitter.com%')
->orWhere('url', 'like', '%instagram.com%')
Answer the question
In order to leave comments, you need to log in
The first option creates a subquery, thus grouping the queries.
The second option should not work for a long time. Make sure you put in the correct indexes.
I also advise you to use Debugbar: https://github.com/barryvdh/laravel-debugbar
Monitor slow requests, and then execute the request with the EXPLAIN prefix. Mysql itself will explain why the query is slow (no indexes are used, a temporary table is created, etc.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question