PHP-Code:
// prüft ob eine ID in DB existiert
function check_id($id)
{
if ($id == 0) {
AppErrorCollection::addErrorMessage('Bitte keine Nullen verwenden');
}
$result = db_result(db_query('SELECT COUNT(*) FROM data WHERE id = ' . $id));
if (!is_numeric($result)) {
// $result könnte false oder null sein
throw new DatabaseException('Could not query for ID', $result);
}
return (bool) $result;
}
// irgendwo im View folgt dann
AppErrorCollection::printErrorMessages();
Da kommt deine prozedurale Denke wieder zum Vorschein. 

Einen Kommentar schreiben: