A
A
Alexander Ivanov2018-08-13 13:16:17
Laravel
Alexander Ivanov, 2018-08-13 13:16:17

How to properly split builder into parts?

seems to be true according to the examples, however, it produces an array with the capabilities of the builder

// так отрабатывает
            $queryRes = Customer::query() // DB::table('customers')
                ->selectRaw('count(*) as subs')
                ->where('site_id', '=', $site_id)->get();
// а так  
            $queryRes = Customer::query(); // DB::table('customers')
            $queryRes->selectRaw('count(*) as subs')
                ->where('site_id', '=', $site_id)->get();
// нет (
//  причём не важно где разбиваю

what it returns in the second case
{
"connection": {},
"grammar": {},
"processor": {},
"bindings": {
"select": [],
"from": [],
"join": [],
"where": [
"1"
],
"having": [],
"order": [],
"union": []
},
"aggregate": null,
"columns": [
{}
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-08-13
@cimonlebedev

well, you don’t write down the result anywhere ...
You can make parts of the condition, etc.
But get must be written somewhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question