mercredi 1 juillet 2020

Laravel 5.5 close Postgresql database connection

I searched on web but not found a solution to my problem.

My environment:

  • Laravel 5.5
  • PHP 7.2
  • Postgresql 12.3
  • Ubuntu 18.4

My problem is that DB::disconnect() doesn't close the connection.

My project have multiple database connection to Postgre and many jobs that use this connection.

Inside the job I want to disconnect from the default connection and connect to a specific one.

So if I run multiple times the job, it will create multiple connection and never close the old one.

I tried with DB::reconnect(), DB::disconnect() and DB::purge(), but the connection still open.

I read that the PDO connection is close when all references are set to null, it is possible that the framework keep some reference to the PDO connection and so it will never close?

I tried to make a simple script like:

DB::connect('some_connection'); 
DB::disconnect('some_connection'); 

But I can see the connection open on my database.

Any solutions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire