Wainwright (5-3) struck out six and retired the last 10 batters he faced as he moved to 10-1 with a 1.56 ERA over his career against Colorado.
Yadier Molina extended his hitting streak to 16 games with a run-scoring single in the third. Pham had the big blow in the fifth, when he lined a slider from Rockies left-hander Kyle Freeland (5-3) into the left-center seats.
The Cardinals withstood a scare in the eighth, with Trevor Rosenthal working his way out of a bases loaded jam by getting Carlos Gonzalez to ground out. Seung Hwan Oh pitched the ninth for his 11th save in 13 chances.