How can I write my code to attempt a database action but continue executing code on failure?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-04-05T16:35:33Z Indexed on 2010/04/05 16:43 UTC
Read the original article Hit count: 110

Filed under:

Simple question I guess, I want to use PHP to write an update to an existing row in my database, if it doesn't happen I want to log the failure but continue executing the code. While it would be nice to have records of failures to track down issues, that the update failed isn't that important to my user, nor will it affect the running of any other code; the query is simply for a 'cosmetic' but entirely unnecessary piece of information.

My database class's query function is set to die on failure, could I modify that or is there another way of doing it without altering my standard query code?

© Stack Overflow or respective owner

Related posts about php