Jump to content

Redundant Query?


benanamen

Recommended Posts

I was reviewing code from an old practice project for a user reg/login. The activate reg and password reset code first queries if there is a valid hash, then runs the update query. Seems to me it should be just like a registration where you attempt the insert (in this case UPDATE) and catch the failure if any which would eliminate half the code.

 

Interested in anyone's feedback.

Link to comment
Share on other sites

Without understanding the entire workflow, I would say you are correct.

 

The current code (run a select to check for the hash and then run the update) could create a problem with a race condition - if the hash could be changed/deleted. But, there could be legitimate reasons to run a select first and run different branches of logic before proceeding to an update.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.