I wrote following code in my laravel application. This code is fetching data from four different tables and every table has totally different columns.
$response = [];
$response['test1'] = DB::table('test1')
->where('user_id','=',$user->id)
->whereNull('deleted_at')
->get();
$response['test2'] = DB::table('test2')
->where('user_id','=',$user->id)
->whereNull('deleted_at')
->get();
$response['test3'] = DB::table('test3')
->where('user_id','=',$user->id)
->whereNull('deleted_at')
->get();
return ['success' => true,'data' => $response, 'errors'=> null];
Now just for curiosity, I want to know how this code will run.
- How many connections will Laravel create while running the following queries?
- If it creates a new connection for every single query then how it will affect my application if my DB server is on a different continent?
- And If it creates a single connection then for how much time the connection persists?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire