搜索引擎开发使用mysql相关性,不在php上工作

9vw9lbht  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(264)

我正在开发搜索引擎。我正在努力处理一个sql/php请求。我正在尝试从搜索查询中获得最高的相关性分数。它在sql上运行得很好,但在php上却完全不工作,既不在localhost上,也不在online上(而源代码是由phpmyadmin本身生成的)。

$connect = mysqli_connect('a', 'b','c','d');    
    $sql1 = "SELECT job, MATCH (job)  AGAINST (\'sales representative\' IN BOOLEAN MODE) AS score FROM general_comp ORDER BY score DESC limit 1";
    $result = mysqli_query($connect, $sql1); 

    echo $result;

显然,sql连接是有效的,因为其他请求工作得很好。你知道吗?
来源=https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html

jecbmhm3

jecbmhm31#

您需要从资源获取结果 $result :

$connect = mysqli_connect('a', 'b','c','d');    
$sql1 = "SELECT job, MATCH (job)  AGAINST (\'sales representative\' IN BOOLEAN MODE) AS score FROM general_comp ORDER BY score DESC limit 1";
$result = mysqli_query($connect, $sql1); 
$row = mysqli_fetch_assoc($result);
print_r($row);

相关问题