Cybersupernova
Cybersupernova

Reputation: 1839

How to close mysql connections explicitly in zend framework?

I'm successfully using ZF2.2 Everything was working fine until a requirement arised to close the sql connection explicitly. I know PHP closes all extra db connections after some time. But I wanted to do this explicity something like $adapter->closeConnection();

Please tell me there is something which can help me.

Upvotes: 2

Views: 2642

Answers (2)

Lars Nyström
Lars Nyström

Reputation: 6373

If you have the adapter in $adapter, this should work:

 $adapter->getDriver()->getConnection()->disconnect();

Upvotes: 5

satchcoder
satchcoder

Reputation: 797

You should get the db_adapter and then get the connection (getConnection()) and with this object you will be able to use the disconnect() method.

Upvotes: 2

Related Questions