public function addTagsForUser($phrase, $userId) { // split phrase into individual tags $tags = Tag::splitPhrase($phrase . ' ' . sfConfig::get('app_permanent_tag')); // add tags foreach ($tags as $tag) { $questionTag = new QuestionTag(); $questionTag->setQuestionId($this->getId()); $questionTag->setUserId($userId); $questionTag->setTag($tag); try { $questionTag->save(); } catch (PropelException $e) { // duplicate tag for this user and question } } }