Sounds like you are using the free rotation commands to rotate your object (dbTurnObjectLeft etc..), these dont work in euler angles which is what you want.
You need to use dbRotateObject() to keep the angles euler(0 - 360), the problem may be if you need to use the free rotation commands, if you have to use these then you I think you may need to keep track of the angles yourself.
I have not tried this but declare your own angle variables x,y,z; then when you use dbTurnObjectLeft(id, 10) then you also do y = y - 10.
Like I said, this is just a theory.