如何获取MySQL's 'ft_min_word_len'使用PHP配置变量


How can I get the value of MySQL's 'ft_min_word_len' configuration variable using PHP?

我知道如何正确更改MySQL ft_min_word_len配置变量,但我似乎无法在PHP中轻松找到。MySQL文档(也许我没有使用正确的搜索条件)是,如果有一种方法,以编程方式获得ft_min_word_len使用PHP的值。我的搜索引擎应该抛出一个错误,如果查询包含搜索条件短于ft_min_word_len,这将是有帮助的,如果它可以自动做到这一点,而不需要我记得设置一个变量。

您可以使用show variables并从php中检索它的值。

show variables like 'ft_min%'
从php

$query = mysql_query("show variables like 'ft_min%'") or die(trigger_error());
$num = mysql_fetch_row($query);
echo $num[1];

仅供参考,您甚至可以从information_schema

中获得此值
select variable_value from information_schema.global_variables
where variable_name like 'ft_min%'