I am wondering if there is a best practice or standard query used to check if a MySQL database is still connected?
I was originally thinking of performing a simple search in one of my tables, which will confirm if the database is still there. Just wondering if there is a better approach.
No need to actually
selectfrom a table. You could just do:This is a very cheap query, that will error if the database is not connected. The
1does not really matter (the important point is to not have afromclause). You could as well useselect null, orselect 'foo'.