Open catchem99 opened 5 years ago
There's no simple way to do this in PDO. Documentation suggests:
To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted—you do this by assigning null to the variable that holds the object.
Note: If there are still other references to this PDO instance (such as from a PDOStatement instance, or from other variables referencing the same PDO instance), these have to be removed also (for instance, by assigning null to the variable that references the PDOStatement).
I didn't manage to do this, so I destroy this connection from mysql itself.
public function close()
{
// this line does the job
try { $this->pdo->query('KILL CONNECTION_ID()'); } catch (\PDOException $e) {}
// this should close the connection, but doesn't.
return $this->pdo = $this->connection = $this->container = $this->pdoStatement = null;
}
try/catch to dismiss Fatal error: 1317 Query execution was interrupted
May be someone can do it correctly with nulls to make it more cleaner.
But it tested and works with this mysql trick.
@usmanhalalit ?
Can pixie close a connection? It's not in the documentation..