No officer or employee of the city or of any of the counties within its limits shall detail or cause any officer or employee of the city or of any of such counties to do or perform any service or work outside of the public office, work or employment of such officer or employee; and any violation of this section shall constitute a misdemeanor.