Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 973
morgant Avatar asked Apr 19 '11 12:04

morgant


1 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%'
like image 157
Nicola Cossu Avatar answered Nov 12 '22 08:11

Nicola Cossu