我正在创建一个在线系统,将银行对账单(描述、价值、类型等)与购买者(姓名、地址)相匹配,并希望对我目前这样做的方式提供一些反馈:
$array = array("keywords", "taken", "from",
"bank", "statements", "using", "explode",
"function", "using", "a", "space");
$i = 0;
$r = array(); //r = relevant
while($i<count($array)) {
$keyword = $array[$i];
$get = mysql_query("SELECT `id` FROM `users`, `addresses`
LEFT JOIN `users`.`id` = `addresses`.`user`
WHERE (`users`.`frame` LIKE '%$keyword%'
OR `users`.`lname` LIKE '%$keyword%')
OR ((`addresses`.`address` LIKE '%$keyword%'
OR `addresses`.`town` LIKE '%$keyword%')
OR (`addresses`.`county` LIKE '%$keyword%'
OR `postcode`.`town` LIKE '%$keyword%'));");
if(mysql_num_rows($get)) {
while($fetch = mysql_fetch_array($get)) {
list($var) = $fetch;
push_array($r, $var);
}
}
$i++;
}
//count the IDs that match within the relative array to see
//which is most relative to the search
有没有更好的方法来做到这一点以及将执行时间保持在最低限度?数据库完成后将达到数千个。