Sunday, June 7, 2009

My worst production fail

In respond to http://thedailywtf.com/Articles/A-Classic-Production-Failure.aspx my worst production fail was almost classic but a little different. I was green and just started to work in a small company.

Consider the following sql statement in PHP:

UPDATE table SET balance = $sum - $amount
what if $amount less than zero

UPDATE table SET balance = 50 - -10
-- means comment, no -- equals to + in SQL

and what we have is not what we wanted - every record with balance = 50

That was my epic production fail. Backup and stored balance transactions records saved my day.

Don't use such stupid statements...