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.

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

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路