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

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

Posted by: admin January 31, 2018 Leave a comment

Questions:

I know how to properly change the MySQL ft_min_word_len configuration variable, but what I can’t seem to easily find in the PHP & MySQL documentation (maybe I’m not using correct search terms) is if there’s a way to programatically get the value of ft_min_word_len using PHP. My search engine should throw an error if the query contains search terms shorter than ft_min_word_len and it’d be helpful if it could do it automatically without me remembering to set a variable.

Answers:

You can use show variables and retrieve its value from php.

show variables like 'ft_min%'

From php

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

Just for your information you can get this value even from the information_schema

select variable_value from information_schema.global_variables
where variable_name like 'ft_min%'