My left leg gave away while climbing stairs. Almost fell but didn't. Doctor checked out and said it is manifestation of pain. Thoughts?

Protection. The body protects itself. When you have a small bit a cartilage floating around the knee joint and go to bear weight, your body stops you from injuring itself. The giving way is your body not allowing to bring your full weight down and injuring the surface of the joint further.
But why pain? Knee pain can certainly cause your knee to buckle. If it keeps happening you need to find out why. A good history and physical exam and possibly x-ray is a good place to start.