Use db->makeArray() instead of loops