Except when otherwise provided by law, any officer or employee of a city is entitled to receive the salary, fees, or other compensation fixed by ordinance or resolution. After having been once fixed, the salary of an officer may not be diminished to take effect during the term for which the officer was elected or appointed.