Ah, speaking of code snippet of the day. Found someone’s code trying to check if a promo-code is already used, and if not to apply it:
$codes = $db->exec(‘SELECT code from promocode’);
if (!in_array($myCode, $codes)){
// use it
}