How can I restrict php mail() to only send me one email after a db error

I’m not sure that this is a good idea, email is just not a good medium for emergency messages (who will see the email when you are a sleep or at the beach?), and if you want to monitor the site it is better done by external service which will probably be able to send you an SMS or make a phone call.

That being said, if you want to still send emails, you need to store the last error time in a separate file, and before sending a mail read the file and check when was the last time a mail was sent. The important detail here is that the file need to be writable by the web server. It is probably a good idea to locate it outside of the web root on your server.