public function actionIndex() { if (Yii::$app->getRequest()->getMethod() === 'OPTIONS') { return true; } return new ActiveDataProvider(['query' => Dictionary::find(), 'pagination' => ['pageSize' => 1]]); }
public function actionDictionary($seqLength = 4, $appearance = 1) { $this->seqLength = $seqLength; $this->appearance = $appearance; $startTime = microtime(true); $x = 0; $dictionary = Dictionary::find()->where(['>', 'LENGTH(word)', $seqLength])->all(); Sequence::deleteAll(); foreach ($dictionary as $entry) { if ($x % 1000 == 0) { echo "{$x}\n"; } $x++; // Some simple checks on our word if ($this->checkWordLength($entry->word) && $this->checkSeqPossible($entry->word)) { // everything OK so lets continue for ($i = 0; $i + $this->seqLength - 1 < strlen($entry->word); $i++) { $str = strtolower(substr($entry->word, $i, $this->seqLength)); if (preg_match('/\'|[0-9]/', $str) === 0) { $exists = Sequence::find()->where(['like', 'letters', $str])->exists(); if (!$exists) { $count = Dictionary::find()->where(['like', 'word', $str])->count(); $seq = new Sequence(); $seq->letters = $str; $seq->count = $count; $seq->word = $entry->word; $seq->save(); } unset($exists); } } } } echo "Elapsed time is: " . (microtime(true) - $startTime) . " seconds \n"; // var_dump($dictionary); }
public function actionFoo() { return new ActiveDataProvider([ 'query' => Dictionary::find()->where(['like','word','abb']), ]); }