$i = 0; while ($dbRow = mysql_fetch_assoc($dbResult)) { $i++; $word = new Word(); $word->populateFromDbRow($dbRow); $definitionId = $word->conceptId; // We changed the column name already print "{$i}/{$numRows} " . $word->name . "... "; if ($exponent->name == $word->name) { // We already have a concept created for this name $conceptId = $exponent->conceptId; migrateDeclensionModels($word->id, $exponent->id); $word->delete(); print "deleted.\n"; } else { $concept = Concept::create($word->name, ''); $concept->save(); $conceptId = db_getLastInsertedId(); $conceptIdToWordsMap[$conceptId] = array($word->name => $word->id); $word->conceptId = $conceptId; $word->save(); $exponent = $word; print "created concept.\n"; } $definitionIdToConceptIdMap[$definitionId] = $conceptId; $cdm = ConceptDefinitionMap::create($conceptId, $definitionId); $cdm->save(); } mysql_free_result($dbResult); // Go through all the words having Priority > 0 $dbResult = mysql_query("select * from Word where Priority > 0");