replace IF() with CASE/WHEN (part #1)
another IF() -> CASE...WHEN conversion
use more portable LIMIT ... OFFSET syntax instead of LIMIT x,y
Merge branch 'hartmut-php/no-mysql-functions'

https://code.launchpad.net/~hartmut-php/eventum/no-mysql-functions