Welcome Guest, Not a member yet? Register   Sign In
Insert and Update database checking
#9

(This post was last modified: 12-28-2015, 01:14 AM by Diederik.)

I think it's just bad practise to just display a message like "page was saved" when some posted data is validated. You did not verify a single row was affected.
I can think of numerous situation were this can go wrong. You could have some mistake in your database scheme for example where you forgot to make an id field (or url slug etc) a unique field and you end up having 2 different pages with the same id/slug after a manual import of a .sql file from a live environment or something.
Or the database could be in read only mode for some server related issue, or your database user does not have write access to a particular table etc.

I have setup a routine to check for these kind of unexpected results when the effected rows does not match the expected value, or when an insert on a auto increment table does not return a new id etc. I generate an error message and write the event to a log.

To omit some checks out of laziness can it ever be best practise.

That being said, the chances of something like this is very limited but still i don't feel comfortable omitting these checks to save a few hours of dev time. Whenever you need to debug a situation you should be happy you have spend those few hours because they will pay off!
Reply


Messages In This Thread
RE: Insert and Update database checking - by Diederik - 12-28-2015, 01:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB