Reputation: 73
in controller.php (parent class)
function __construct() {
DB::disconnect('DataBase');
}
child class of parent class
i disconnect the database globally and reconnect the needed functions in child class
public function getDomain()
{
DB::reconnect('DataBase');
$select = "select * from product";
$execute = DB::select($select);
print_r($execute);
return view('test');
}
without DB::reconnect function data's are fetched from DB,so am also tried disconnect the DB directly subclass function and also data's are fetched so DB connection is properly not closed.
in laravel 5.7 DB::disconnect & DB::reconnect working or not..
Upvotes: 1
Views: 2160
Reputation: 73
Now i am clearly understood.. i thought once i disconnect the database, does not work any queries corresponding database. but it will automatically reconnect the default database when i execute the queries.
Upvotes: 2