I'm curious. How many queries does this style get you ?
$users = User::with(array('achievements' => function($query)
{
$query->where('title_id', '=', $this->title_filter_id);
}))->get();
It queries as expected but does so very slowly in 9.21 seconds compared to when using
DB::select( DB::raw( "complex query goes here" ), [ $this->title_filter_id ] );
which returns in 372.04 milliseconds
The returned query by using DB::with()
returns the correct result when run directly on phpmyadmin giving only 19 User rows.
But the model returns the whole table (4,888 User records).
oh and to answer your question, only 2 queries where run :smiley:
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community