Hey internals, I've submitted https://github.com/php/php-src/pull/5935 as a way to expose an underlying PDO driver's check_liveness function to userland scripts. Often advice given on the internet is to issue a no-op statement (e.g. SELECT 1 FROM dual), but this adds potentially unnecessary overhead and latency. Using the PDO driver's check_liveness function offers a lower-cost way of ensuring the connection is still alive.
As noted in the PR, I am not tied to the method name, and open to any suggestions to making the PR better - I'm mostly interested in the underlying concept. It appears the test I added is currently failing for pgsql. I didn't have a test setup for that on hand but will look into it if there is positive feedback for this PR. Relatedly, I've also submitted https://github.com/php/php-src/pull/5947 as a way to potentially improve the mysqlnd driver's check_liveness function. Thanks! Eric Norris