protected function addNewWords($allWords)
    {
        try {
            $newWords = $allWords;
            $query = (new Query())->from(Vocabulary::tableName())->where(['word' => $allWords]);
            foreach ($query->each() as $vocabularyFound) {
                if (($key = array_search($vocabularyFound['word'], $allWords)) !== false) {
                    unset($newWords[$key]);
                }
            }
            $formatWords = [];
            foreach ($newWords as $word) {
                $formatWords[] = [$word];
            }
            if (!empty($formatWords)) {
                if (!Podium::getInstance()->db->createCommand()->batchInsert(
                        Vocabulary::tableName(), ['word'], $formatWords
                    )->execute()) {
                    throw new Exception('Words saving error!');
                }
            }
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
            throw $e;
        }
    }
protected function addNewWords($allWords)
    {
        try {
            $newWords = $allWords;
            $query = (new Query())->from(Vocabulary::tableName())->where(['word' => $allWords]);
            foreach ($query->each() as $vocabularyFound) {
                if (($key = array_search($vocabularyFound['word'], $allWords)) !== false) {
                    unset($newWords[$key]);
                }
            }
            $formatWords = [];
            foreach ($newWords as $word) {
                $formatWords[] = [$word];
            }
            if (!empty($formatWords)) {
                if (!Podium::getInstance()->db->createCommand()->batchInsert(
                        Vocabulary::tableName(), ['word'], $formatWords
                    )->execute()) {
                    throw new Exception('Words saving error!');
                }
            }
        } catch (Exception $e) {
            Log::error($e->getMessage(), null, __METHOD__);
            throw $e;
        }
    }
protected function addNewWords ( $ allWords ) { try { $ newWords = $ allWords ; $ query = ( new Query ( ) ) -> from ( Vocabulary :: tableName ( ) ) -> where ( [ 'word' => $ allWords ] ) ; foreach ( $ query -> each ( ) as $ vocabularyFound ) { if ( ( $ key = array_search ( $ vocabularyFound [ 'word' ] , $ allWords ) ) !== false ) { unset ( $ newWords [ $ key ] ) ; } } $ formatWords = [ ] ; foreach ( $ newWords as $ word ) { $ formatWords [ ] = [ $ word ] ; } if ( ! empty ( $ formatWords ) ) { if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( Vocabulary :: tableName ( ) , [ 'word' ] , $ formatWords ) -> execute ( ) ) { throw new Exception ( 'Words saving error!' ) ; } } } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; throw $ e ; } }
Adds new tag words.
@param string[] $allWords All words extracted from post
@throws Exception
Adds new tag words .