0
<?php function ss($s1, $s2, $s3, $s4, $s5, $s6) {
$sonucArray = array("alti" => 0, "bes" => 0, "dort" => 0, "uc" => 0, "iki" => 0);
$sayiArray = array($s1, $s2, $s3, $s4, $s5, $s6);
$sayiArraySql = join(',',$sayiArray);
$query = mysql_query("select * from loto where
s1 in ($sayiArraySql) or
s2 in ($sayiArraySql) or
s3 in ($sayiArraySql) or
s4 in ($sayiArraySql) or
s5 in ($sayiArraySql) or
s6 in ($sayiArraySql)");
while ($record = mysql_fetch_array($query)) {
$controlArray = array($record["s1"],$record["s2"],$record["s3"],$record["s4"],$record["s5"],$record["s6"]);
$diffArray = array_diff($sayiArray,$controlArray);
if (count($diffArray) == 0)
$sonucArray["alti"]++;
else if (count($diffArray) == 1)
$sonucArray["bes"]++;
else if (count($diffArray) == 2)
$sonucArray["dort"]++;
else if (count($diffArray) == 3)
$sonucArray["uc"]++;
else if (count($diffArray) == 4)
$sonucArray["iki"]++;
}
return $sonucArray;
}
mysql_fetch_array;使用太多CPU並且不快!針對MySQL查詢的優化 - 獲取PHP
「s1-s2-s3-s4-s5-s6」是整數。
取而代之的應該是一個代碼?我知道PHP不足。有人建議我「mysql_fetch_row」,但我無法通過修改
我應該怎麼寫?
如果您的查詢太慢,請嘗試索引您正在搜索的列。 –
這些列已編入索引。有很多查詢處理 – user1419633