0
我正在獲取xml提要,解析並存儲到數據庫。加快查詢內循環?
歐洲飼料有時候會有一些球隊,比如哪個國家是歐洲,而不是英格蘭,德國,塞爾維亞等。只是歐洲,所以我創建了包含所有國家隊列的所有國家和地圖表。
所以我要檢查團隊內表地圖,國家= $ countryfromarray,這作品時,我有一個團隊,例如嘗試,但我得到的團隊從飼料,飼料中的約5000支球隊。
if((strtolower($country) == 'southamerica') or (strtolower($country) == 'conmebol')){
$countries = $this->conmebolarray;
$isregion = true;
}
elseif((strtolower($country) == 'europe') or (strtolower($country) == 'uefa')){
$countries = $this->euroarray;
$isregion = true;
}
elseif((strtolower($country) == 'asia') or (strtolower($country) == 'afc')){
$countries = $this->afcarray;
$isregion = true;
}
elseif((strtolower($country) == 'africa') or (strtolower($country) == 'caf')){
$countries = $this->cafarray;
$isregion = true;
}
elseif((strtolower($country) == 'northandcentralamerica') or (strtolower($country) == 'concacaf')){
$countries = $this->conarray;
$isregion = true;
}
else{
$countries = $country;
$isregion = false;
}
//$res = '';
if($isregion){
$query = $PDO->prepare($sql);
$newcountry = '';
foreach($countries as $loopcountry){
$query->bindValue(':data', $data);
$query->bindValue(':country', $loopcountry);
//
if($query->execute())
{
if($query->rowCount()>0){
$res = $query->fetchColumn();
$newcountry = $loopcountry;
break;
}
$query->closeCursor();
}
}
國家的陣列和:
//"southamerica" & "conmebol" & "CONMEBOL";
public $conmebolarray = array('argentina','brazil','chile','colombia','paraguay','uruguay','venezuela','peru','bolivia','ecuador','newzealand');
//"europe" & "uefa" & "Europe" & "UEFA";
public $euroarray = array('england','france','germany','italy','spain','scotland','albania','andorra','armenia','austria','azerbaijan','belarus','belgium','bosnia','bulgaria','croatia','cyprus','czech','denmark','estonia','faroeislands','georgia','gibraltar','greece','hungary','iceland','israel','kazakhstan','latvia','liechtenstein','luxembourg','malta','moldova','montenegro','netherlands','northernireland','norway','poland','portugal','ireland','romania','russia','sanmarino','serbia','slovakia','slovenia','sweden','switzerland','turkey','ukraine','wales','europe');
//"asia" & "afc" & "Asia" & "AFC";
public $afcarray = array('australia','japan','korea','singapore','china','qatar','saudiarabia','vietnam','bahrain',
'bangladesh','bhutan','brunei','cambodia','chinesetaipei','guam','hongkong','india','indonesia','iran','iraq','japan','korea',
'northkorea','kuwait','kyrgyzstan','laos','lebanon','macau','malaysia','maldives','mongolia','myanmar','nepal',
'northernmarianaislands','oman','pakistan','palestine','philippines','srilanka','syria','tajikistan','thailand','timorleste','turkmenistan','uae','uzbekistan','yemen','newzealand','asia','afc');
//"africa" & "caf" & "Africa" & "CAF";
public $cafarray = array('nigeria','southafrica','egypt','tunisia','algeria','morocco','cameroon','drcongo','ivorycoast','ghana','djibouti','eritrea','ethiopia','kenya','rwanda','somalia','southsudan','sudan','tanzania','uganda','zanzibar','angola',
'botswana','comoros','lesotho','madagascar','malawi','mauritius','mozambique','namibia','seychelles','swaziland','zambia',
'zimbabwe','reunion','burundi','saotomeandprincipe','gabon','equatorialguinea','congo','chad','centralafricanrepublic','togo',
'sierraleone','senegal','niger','mauritania','mali','liberia','guineabissau','guinea','gambia','capeverde','burkinafaso',
'benin','libya','africa','caf');
//"northandcentralamerica" & "concacaf" & "CONCACAF";
public $conarray = array('usa','mexico','canada','costarica','elsalvador','guatemala','honduras','trinidadandtobago','jamaica',
'panama','honduras','haiti','cuba','belize','dominicanrepublic','bermuda','aruba','barbados','grenada','surinam',
'guadeloupe', 'antigua','antiguaandbarbuda','saintvincent','saintvincentandthegrenadines','saintkittsandnevis',
'saintlucia','nicaragua','curacao','puertorico','guyana','dominica','usvirginislands','montserrat','caymanislands',
'turksandcaicos','turksandcaicosislands','britishvirginislands','bahamas','anguilla','frenchguiana','martinique',
'saintmartin','sintmarteen','bonaire','concacaf','northandcentralamerica');
而且GetMap操作過程
CREATE PROCEDURE GetMap(p_team VARCHAR(100), p_country VARCHAR(100))
BEGIN
SELECT Base FROM map WHERE
(map.Base = p_team OR
Ver1 = p_team OR
Ver2 = p_team OR
Ver3 = p_team OR
Ver4 = p_team OR
Ver5 = p_team OR
Ver6 = p_team OR
Ver7 = p_team OR
Ver8 = p_team OR
Ver9 = p_team OR
Ver10 = p_team OR
Ver11 = p_team OR
Ver12 = p_team) AND Country = p_country;
end //
DELIMITER ;
感謝您的回覆和建議,但這不是解決方案。 問題是,我的進料裝入非常多的時間(抱歉英國)中,當i相陣列I加快和飼料被加載10秒鐘除去代碼,當我使用此陣列它加載約2分鐘只有一個進料。問題是在PHP的一部分,我也許是如何執行的,當我移動執行外循環,然後是好多了,但它是沒有用的... – DocNet
也許唯一的辦法是爲每個區域的程序,然後檢查,其中國家=「英格蘭'等等...... – DocNet