是否可以以任何方式减少执行的查询?因为我现在这样做的方式还可以,但后来我可以得到 30 个查询,这对我来说看起来不太好
我的脚本
$string = 'new movie stars';
$words = preg_split('/(\/|\s+)/', $string);
print_r($words);
数组( [0] => 新 [1] => 电影 [2] => 星星)
$sql = "SELECT * FROM movie WHERE MATCH(name) AGAINST('+$words[0] +$words[1] +$words[2]' IN BOOLEAN MODE)";
$query_name = $this->db->query($sql);
if ($query_name->num_rows < 20) {
$sql = "SELECT * FROM movie WHERE MATCH(name) AGAINST('+$words[0] +($words[1] $words[2])' IN BOOLEAN MODE)";
$query_name_two = $this->db->query($sql);
}
if (count($query_name->num_rows + $query_name_two->num_rows) < 20) {
$sql = "SELECT * FROM movie WHERE MATCH(name) AGAINST('$words[0] $words[1] $words[2]' IN BOOLEAN MODE)";
$query_name_three = $this->db->query($sql);
}
智慧大石