As the saying goes ... don't bang crazy -- something "Hangover" director Todd Phillips shoulda known back in 2011, when he claims he had a one-night stand with the woman who's allegedly been stalking him.
Todd obtained a temporary restraining order today against 22-year-old Juliana Shiao, claiming she's been harassing him non-stop since he had a "one-night relationship" with her nearly two years ago. Kinda like "Fatal Attraction" ... without the bunny boiling.
In the legal docs, Todd says he met her on a movie set the year before -- and after their night together, she went off the rails ... texting him non-stop, showing up at his house, and even following him to Vegas last November.
After the Vegas scare, Todd says Shiao showed up at his L.A. home and destroyed his girlfriend's car -- kicking it in and tearing off the windshield wipers -- after texting him things like, "I really don't wanna be a stalker ... I'm going to hop over your fence ... [and] smash your girlfriend's car if you don't come out."
TMZ broke the story ... Shiao was arrested outside Todd's home last week on suspicion of stalking -- and in the court docs, Todd says it seemed she had been secretly staying in his pool house for days.
Shiao pled "not guilty" today to the felony stalking charge. A hearing is set for later this month to determine whether Todd's civil restraining order will be made permanent.