We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Database reconnect

Hello,

how can I tell, if the DB connection is alive and reconnect if not? (I'm making the daemon app which should run forever but MySQL drop connections after timeout).

Thanks.



8.6k

Hi,

I'm new to phalconphp, but you could call connect() on the database adapter in your controller/main loop to make sure the connection "it's alive" . PDO should reuse present connections, so no new connections should be created. Otherwise write an own solution utilizing mysqli_ping .