`$has_attachment = (bool) $this->db->sql_fetchfield('nb_attachments');`
Also avoid inline assignments