Can one and if yes how can one write a Php MySQL command that tells Php

SELECT this command from MySQL
but if it takes more than 5 Seconds to get an answer from MySQL regarding this
SELECT then stop waiting for it and instead return 0 (or X) and go on to the
next command.