ML: Database addphoto function flattened