Hello.
I'm trying to understand how query builder is forming SQL requests, messing with DB::selectRaw(...)->where(...)->whereRaw(...) ; and joinSub(..) (subqueries)
I'm trying to do less Raw inputs as possible, but to do so in proper way i have to understand how Query builder is forming it's queries: when it adds extra symbols/words and where.
IMHO, the best way to understand Query builder logic is to print formed query string (but not it's result).
is there any way i can see how query looks like for request?
DB::table('cities')->select(DB::raw('CityName, (SELECT MAX(Area) FROM city_areas)'))->where('Translit', $c)
dd(
DB::table('cities')->select(DB::raw('CityName, (SELECT MAX(Area) FROM city_areas)'))->where('Translit', $c)->toSql()
);
->toSql() is easier way to do so and do not rely on server response. Even if you've made a mistake in your request you'll still be able to get a request string