Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

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();
0

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:

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.