public static function regenerateAllWordLetters() { SqlDeleteRows('delete from word_letter', array()); $words = SqlFetchRows("select * from word", array()); SqlEchoOn(); foreach ($words as $thisWord) { Learn::generateWordLetters($thisWord); } }
public function getWords() { $words = array(); for ($row = 1; $row <= self::size; $row++) { $word = ''; for ($col = 1; $col <= self::size; $col++) { $letter = $this->cells[$row][$col]->getLetter(); if ($letter) { $word .= $letter; } else { if ($word) { $words[$word] = 1; $word = ''; } } } if ($word) { $words[$word] = 1; $word = ''; } } for ($col = 1; $col <= self::size; $col++) { $word = ''; for ($row = 1; $row <= self::size; $row++) { $letter = $this->cells[$row][$col]->getLetter(); if ($letter) { $word .= $letter; } else { if ($word) { $words[$word] = 1; $word = ''; } } } if ($word) { $words[$word] = 1; $word = ''; } } // SqlEchoOn(); foreach ($words as $thisWord => $thing) { SqlBeginTransaction(); $word = strtoupper($thisWord); $len = strlen($word); if ($len < 2) { continue; } $id = SqlFetchCell("select id from word where word = :word", array('word' => $word)); if (!$id) { echo "inserting word: {$word}<br>"; SqlInsertRow("insert into word (word, len) values (:wordwrap, :len)", array('word' => $word, 'len' => $len)); Learn::generateWordLetters($word); } SqlCommitTransaction(); } }