original_string: protected function updateWords()
      {
          try {
              $vocabulary = [];
              $allWords = $this->prepareWords();
              $this->addNewWords($allWords);
              $queryVocabulary = (new Query())->from(Vocabulary::tableName())->where(['word' => $allWords]);
              foreach ($queryVocabulary->each() as $vocabularyNew) {
                  $vocabulary[$vocabularyNew['id']] = [$vocabularyNew['id'], $this->id];
              }
              if (!empty($vocabulary)) {
                  if (!Podium::getInstance()->db->createCommand()->batchInsert(
                          '{{%podium_vocabulary_junction}}', ['word_id', 'post_id'], array_values($vocabulary)
                      )->execute()) {
                      throw new Exception('Words connections saving error!');
                  }
              }
              $queryJunction = (new Query())->from('{{%podium_vocabulary_junction}}')->where(['post_id' => $this->id]);
              foreach ($queryJunction->each() as $junk) {
                  if (!array_key_exists($junk['word_id'], $vocabulary)) {
                      if (!Podium::getInstance()->db->createCommand()->delete(
                              '{{%podium_vocabulary_junction}}', ['id' => $junk['id']]
                          )->execute()) {
                          throw new Exception('Words connections deleting error!');
                      }
                  }
              }
          } catch (Exception $e) {
              Log::error($e->getMessage(), null, __METHOD__);
              throw $e;
          }
      }
code: protected function updateWords()
      {
          try {
              $vocabulary = [];
              $allWords = $this->prepareWords();
              $this->addNewWords($allWords);
              $queryVocabulary = (new Query())->from(Vocabulary::tableName())->where(['word' => $allWords]);
              foreach ($queryVocabulary->each() as $vocabularyNew) {
                  $vocabulary[$vocabularyNew['id']] = [$vocabularyNew['id'], $this->id];
              }
              if (!empty($vocabulary)) {
                  if (!Podium::getInstance()->db->createCommand()->batchInsert(
                          '{{%podium_vocabulary_junction}}', ['word_id', 'post_id'], array_values($vocabulary)
                      )->execute()) {
                      throw new Exception('Words connections saving error!');
                  }
              }
              $queryJunction = (new Query())->from('{{%podium_vocabulary_junction}}')->where(['post_id' => $this->id]);
              foreach ($queryJunction->each() as $junk) {
                  if (!array_key_exists($junk['word_id'], $vocabulary)) {
                      if (!Podium::getInstance()->db->createCommand()->delete(
                              '{{%podium_vocabulary_junction}}', ['id' => $junk['id']]
                          )->execute()) {
                          throw new Exception('Words connections deleting error!');
                      }
                  }
              }
          } catch (Exception $e) {
              Log::error($e->getMessage(), null, __METHOD__);
              throw $e;
          }
      }
code_tokens: protected function updateWords ( ) { try { $ vocabulary = [ ] ; $ allWords = $ this -> prepareWords ( ) ; $ this -> addNewWords ( $ allWords ) ; $ queryVocabulary = ( new Query ( ) ) -> from ( Vocabulary :: tableName ( ) ) -> where ( [ 'word' => $ allWords ] ) ; foreach ( $ queryVocabulary -> each ( ) as $ vocabularyNew ) { $ vocabulary [ $ vocabularyNew [ 'id' ] ] = [ $ vocabularyNew [ 'id' ] , $ this -> id ] ; } if ( ! empty ( $ vocabulary ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( '{{%podium_vocabulary_junction}}' , [ 'word_id' , 'post_id' ] , array_values ( $ vocabulary ) ) -> execute ( ) ) { throw new Exception ( 'Words connections saving error!' ) ; } } $ queryJunction = ( new Query ( ) ) -> from ( '{{%podium_vocabulary_junction}}' ) -> where ( [ 'post_id' => $ this -> id ] ) ; foreach ( $ queryJunction -> each ( ) as $ junk ) { if ( ! array_key_exists ( $ junk [ 'word_id' ] , $ vocabulary ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> delete ( '{{%podium_vocabulary_junction}}' , [ 'id' => $ junk [ 'id' ] ] ) -> execute ( ) ) { throw new Exception ( 'Words connections deleting error!' ) ; } } } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; throw $ e ; } }
docstring: Updates tag words.
  @throws Exception
docstring_tokens: Updates tag words .