Yes, it would probably be a good idea to see a doctor just to be safe. When I was just a little older than him, I wet the bed and also peed in school. I was diagnosed with type I diabetes a couple months later (after my parents tried everything, I got really ill and lost tons of weight, etc.).
It could be a lot of things, including diabetes or even just a urinary tract infection (not as likely in a boy than a girl, but still possible).
Anyway, like many of the folks on this board, I too have my own story from peeing my pants in elementary school (besides the getting diagnosed with diabetes incident). When I was in the 5th grade I was taking a test that was going to last through the whole 50 minute class I was in. I started feeling like I had to go about ten or fifteen minutes into the test. I asked to go, and my teacher turned down my request and said I had to finish my test first. I went back to my desk and tried, but of course the more and more I had to go, the less and less I could concentrate. I went back again, and the teacher yelled at me and told me I absolutely *had* to finish the test first. Of course by this point I couldn't concentrate at all, but not wanting to fail, I just sat there trying to figure out what the answers were. Eventually class was over and all the other kids went to the computer lab, but I was still sitting there. The teacher actually made me stay and finish the test, and finally after sitting there alone for ten or fifteen more minutes, I just turned in my test, telling her I had done all I could (I had only answered about half the questions, most in haste just trying to finish). I sprinted out of the classroom and ran-- against the rules-- down the hall to the bathroom. Just as I was opening the heavy bathroom door, I lost it. Pee trickled down my leg, and I felt my pants become wet. I dashed in, but it was too late.
I tried my best to dry off my pants with papertowels. Then I took my sweater off and tied it around my waste, and headed to computer lab. I was far too ashamed to tell anyone, though I was mortified when I got home and my older sisters told me they could smell it and that others must have known. Why my computer lab teacher didn't notice and/or intervene, I am not sure.
In any case, I am actually glad your son went to school. I think if he had taken a day off on account of it, he would have had more time to sort of work it up bigger in his mind and imagine fearful things happening when he returned. When my sister hacked all my hair off in a total botch job of a haircut around 5th or 6th grade, my dad forced me to go back to school the next day even when I said I felt sick (he said, rightfully so, that I was sick from anxiety, and that it wasn't going to get easier). My teacher let me wear a hat even though hats were against the rule, and eventually my beloved gym teacher coaxed me to take it off. I was terrified, but pushing through those fears helped me realize that I'd worked them up to be bigger in my mind than they actually were. Sure I got a few comments, but then they were over and done with and the kids moved on to all the other stuff going on.
To this day I have to remind myself that things are always worse when I stress about them in my mind than when they actually happen.
It sounds like the kids were super sweet about it, and that with the one kid who wasn't, like your son handled it BRILLIANTLY. Good for him!