A Nigerian official says at least 40 farmers were killed by militants in a weekend attack in northeastern Borno state.