The county counsel, or if none the district attorney, is the legal adviser of the board of supervisors. The county counsel or if none, the district attorney, shall attend its meetings, when required, and shall attend and oppose all claims and accounts against the county he or she deems unjust and illegal.