i think the real issue here is you became dependent on them..
you went to the doctor complaining about knee pain, you must have tried all the over the counters like ibprofen,rapid 25 and panadol, so he prescribed you something more he was helping you out.. what did you expect from the doctor?
i'm pretty sure everyone in the world knows constipation is a side affect of codeine. and if not little bit of paper that accompanies your tablets the one in about 7 different languages.. well that would list more possible side effects and probably mention not to have on an empty stomach (IE at night)
After reading the paper and returning for repeats you would have know about the issues and relayed them to you doctor
even 90% of pharmacists ask you "have you taken these before?"
i really do hope your feeling better and it's all sorted.
but you can not blame your doctor for this, the responsibility is all on you.