$cnt = 0; foreach ($matches[0] as $match) { $meta1 = "__1"; $meta0 = "__2"; $relation = 1; echo $word0 = mysql_real_escape_string($matches[1][$cnt]); echo "_"; $word1_tmp = str_replace(array("{a}", "{b}"), "", $word1_tmp = $matches[2][$cnt], $amount1); if ($amount1 !== 0) { $relation = 3; } preg_match("/{(3|4)([\\p{L} ~{}:*-]*)}/iu", $word1_tmp, $match); echo $word1 = mysql_real_escape_string($word1_tmp); preg_match_all("/\\[p\\]([^[]*)\\[\\/p\\]/iu", $matches[3][$cnt], $meta); $meta0 = implode(",", $meta[1]); if (strstr($word1, "~")) { #echo "const___".$word0.$word1.str_replace("~",$word0,$word1)."<br/>\n"; $word1 = str_replace("~", $word0, $word1); } echo "<br/>"; if (strstr($word0, "~") !== false) { die("{$word0} contains ~"); } $next_word_id = min(next_word_id($word0), next_word_id($word1)); $result1 = mysql_query(" INSERT INTO word_equivalents_ru (lang,word_id,word_spelling,meta_info,principal,relation)\n VALUES ('ru',{$next_word_id},'{$word0}','{$meta0}',0,{$relation})\n ON DUPLICATE KEY UPDATE meta_info = CONCAT(meta_info,'{$meta0}')"); $result2 = mysql_query("INSERT INTO word_equivalents_ru (lang,word_id,word_spelling,meta_info,principal,relation)\n VALUES ('ru',{$next_word_id},'{$word1}','{$meta1}',1,1)\n ON DUPLICATE KEY UPDATE meta_info = CONCAT(meta_info,'{$meta1}')"); if (!$result1 || !$result2) { die('Ошибка выполнения запроса:' . mysql_error()); } $cnt++; }
mysql_select_db("builder", $db); foreach ($spelling_variants as $variant) { $word0 = mysql_real_escape_string($variant["en_GB"]); $word1 = mysql_real_escape_string($variant["en_US"]); $next_word_id = min(next_word_id($word0), next_word_id($word1)); $result = mysql_query("INSERT INTO en_word_equivalents (lang,word_id,word_spelling,meta_info,principal,relation)\n VALUES ('en',{$next_word_id},'{$word0}','ize',1,1), \n ('en',{$next_word_id},'{$word1}','ise',0,1)"); } //wo_diac //with_diac foreach ($automatic as $variant) { $word0 = mysql_real_escape_string($variant["en_GB"]); $word1 = mysql_real_escape_string($variant["en_US"]); $next_word_id = min(next_word_id($word0), next_word_id($word1)); $result = mysql_query("INSERT INTO en_word_equivalents (lang,word_id,word_spelling,meta_info,principal,relation)\n VALUES ('en',{$next_word_id},'{$word0}','ize',1,1),\n ('en',{$next_word_id},'{$word1}','ise',0,1)"); } foreach ($unrecognized as $variant) { $next_word_id = next_word_id(mysql_real_escape_string($variant['en_GB'][0])); foreach ($variant['en_GB'] as $var) { $next_word_id = min(next_word_id(mysql_real_escape_string($var)), $next_word_id); } foreach ($variant['en_GB'] as $var) { $word = mysql_real_escape_string($var); mysql_query("INSERT INTO en_word_equivalents (lang,word_id,word_spelling,meta_info,principal,relation)\n VALUES ('en',{$next_word_id},'{$word}','ize',-1,1)"); } foreach ($variant['en_US'] as $var) { $next_word_id = min(next_word_id(mysql_real_escape_string($var)), $next_word_id); } foreach ($variant['en_US'] as $var) { $word = mysql_real_escape_string($var); mysql_query("INSERT INTO en_word_equivalents (lang,word_id,word_spelling,meta_info,principal,relation)\n VALUES ('en',{$next_word_id},'{$word}','ise',-1,1)"); } }