Mistři v programování na #hovnokod

PHP #4617

Jak ziskat posledni e-mail? Preci si nacist vsechny z db a vratit prvni.

function getLastEmail($code) {			
    $mails = dibi::fetchAll('SELECT id FROM emails e WHERE e.deleted = 0 AND e.name LIKE %~like~ ORDER BY e.date_entered DESC', $code);

    foreach($mails as $mail) {
        return $mail;
    }
}

Anonymous,