dssqq64884 2015-09-18 17:13
浏览 20
已采纳

php数据库最少4个字母?

php db. Some of my entries in the db are 3 letters (no varchar needed really). When I run searches for these entries I get 0 results.

Not sure if this is set in phpadmin or in my code. I have attached my output snippet, assuming the error is with my line. (I've cut out preg_replace line).

$search_output = "";
if(isset($_POST['searchquery']) && $_POST['searchquery'] != "")
{
$searchquery = preg_replace('#[^a-z 0-9?!]#i', '', $_POST['searchquery']);
$sqlCommand = "SELECT id, a, b, c, d FROM db WHERE a LIKE '%$searchquery%'";
}

And my output snippet:

if($count > 0){
$search_output .= "$count result(s) for $searchquery"};

When the term is 3 letters - assume it is "get", $scount gives 0.

  $search_output = $count results message;

Not sure where my "glitch" is. phpadmin or my code? I suspect my code? But there's nowhere where I assign set a minimum limit....

  • 写回答

1条回答 默认 最新

  • dongshi1869 2015-09-18 17:49
    关注

    You are Mysql with full text search indexes. By default only words with a minimum of 4 characters are indexed. (This is a setting though)

    Read more about it here: https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

    And more specifically here: https://dev.mysql.com/doc/refman/5.0/en/fulltext-fine-tuning.html

    The setting ft_min_word_len defines the minimum word length.

    Depending on the type of search you need to be able to do, the full text search index might not be the thing you should be using. IIRC, for example, you can only search for entire words... So you need to ask yourself if this is what you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办