Skip navigation.
Home

DB Hoopla

How to burn a database in 3 steps...

DB Hoopla

Thanks to Au5lander for sending in this WTF he found on pastebin.com. I'm thinking that this might be some benchmarking code because it'll make the database work so hard!

The code basically goes like this:

  1. If record does not exist, insert data into the first column.
  2. If record exists, update the record with data for the second column
  3. Repeat for each additional column
  4. Watch database burn...

if, if, if, if, else, else, else, else...*sob*

DB Hoopla | Fugly Code

Most of the WTF's I post here are submitted from the readers. Today I give you one from the code I have to maintain. In fact, I started The PHP WTF because of this code base. There are 'jewels' like today's example scattered all over the place. Today's example shone so brightly that I had to share it.

Curly braces are optional for simple IF/ELSE statements in PHP but there is a fine line between clear, concise code and a WTF. Today's code is perfectly valid but you'll probably stare at it trying to match the ELSE statements to the IF statements. I think this is what happens when your brain is screwed in backwards and you haven't learned about ELSEIF yet...

XML feed