<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss">
<channel>
<title>技术教程 - ReiShi</title>
<link>https://reishi.topide.com/</link>
<language>zh</language><item>
<title>修复 infinite 无法模糊搜索的问题</title>
<link>https://reishi.topide.com/tutorials/2-fix-infinite-fuzzy-search-issue.html</link>
<pdalink>https://reishi.topide.com/tutorials/2-fix-infinite-fuzzy-search-issue.html</pdalink>
<guid>https://reishi.topide.com/tutorials/2-fix-infinite-fuzzy-search-issue.html</guid>
<pubDate>Sun, 23 Aug 2026 13:51:43 +0800</pubDate>
<category>index</category>

<content:encoded><![CDATA[<p><a href="https://1.envato.market/VyedBA" title="Infinite 官网" target="_blank" rel="noopener external">Infinite</a>（<a href="https://codingest.com/" title="Codingest 官网" target="_blank" rel="noopener external">Codingest</a> 开发）基于 <a href="https://codeigniter.org/" title="CodeIgniter 框架官网" target="_blank" rel="noopener external">CodeIgniter</a> 框架构建，默认的搜索逻辑使用的是 MySQL 的原生<span style="background-color:#c2e0f4;"> <code>LIKE '%关键词%'</code></span> 查询。</p> <p>中文搜索失效（必须全匹配）的核心原因在于：<b>MySQL 数据库对中文（CJK 字符）没有进行分词索引</b>，且前端或后端在接收搜索参数时，可能进行了不恰当的转义或没有使用通配符包裹。</p> <p>打开 app/Models/PostModel.php 文件，找到下面的代码</p> <pre class="language-php"><code>public function getSearchPostsPaginated($langId, $q, $perPage, $offset) { $this-&gt;buildQuery($langId); return $this-&gt;builder-&gt;where("MATCH(title, summary, content) AGAINST({$this-&gt;db-&gt;escape($q)} IN NATURAL LANGUAGE MODE)")-&gt;limit(clrNum($perPage) + 1, clrNum($offset))-&gt;get()-&gt;getResult(); }</code></pre> <p>替换成</p> <pre class="language-php"><code>// 修改后的搜索方法（改为经典 LIKE 模糊匹配，支持中文任意断句与片段搜索） public function getSearchPostsPaginated($langId, $q, $perPage, $offset) { $this-&gt;buildQuery($langId); // 拆分多关键词（支持空格分隔多词搜索） $keywords = explode(' ', preg_replace('/\s+/', ' ', trim($q))); $this-&gt;builder-&gt;groupStart(); foreach ($keywords as $index =&gt; $word) { if (!empty($word)) { $escapedWord = $this-&gt;db-&gt;escapeLikeString($word); if ($index === 0) { $this-&gt;builder-&gt;groupStart() -&gt;like('posts.title', $escapedWord) -&gt;orLike('posts.summary', $escapedWord) -&gt;orLike('posts.content', $escapedWord) -&gt;groupEnd(); } else { $this-&gt;builder-&gt;orGroupStart() -&gt;like('posts.title', $escapedWord) -&gt;orLike('posts.summary', $escapedWord) -&gt;orLike('posts.content', $escapedWord) -&gt;groupEnd(); } } } $this-&gt;builder-&gt;groupEnd(); return $this-&gt;builder-&gt;orderBy('posts.id', 'DESC') -&gt;limit(clrNum($perPage) + 1, clrNum($offset)) -&gt;get() -&gt;getResult(); }</code></pre> <p>保存上传，尝试搜索，即可实现 中文局部匹配 和 多词模糊 搜索了！</p>]]></content:encoded>
</item><item>
<title>这次，我想慢慢来</title>
<link>https://reishi.topide.com/tutorials/1-hello-again.html</link>
<pdalink>https://reishi.topide.com/tutorials/1-hello-again.html</pdalink>
<guid>https://reishi.topide.com/tutorials/1-hello-again.html</guid>
<pubDate>Sun, 23 Aug 2026 13:31:43 +0800</pubDate>
<category>index</category>

<content:encoded><![CDATA[<p>程序换了又换，数据清了又重来...</p> <p>算起来，这大概是我第 N 次重新建站了。从2002年搭建第一个源码开始，折腾博客似乎成了一种肌肉记忆。以前每次刚搭建好网站，看着新鲜的界面，满脑子都是宏大的计划：要写一个系列教程、要整理一套资源库、要每天更新……然而现实往往是，新鲜感一过，或者工作一忙，更新频率就从“日更”变成“月更”，最后彻底烂尾，默默关站。</p> <p>过一段时间，手又痒了，选源码、配置环境，周而复始。</p> <p>但这次心态变了，不再追求什么华丽的排版，也不给自己设定死板的更新KPI。这个小站，本质上就是我个人的数字后院：</p> <ul> <li> <p><b>记录折腾</b>：记录平日里写代码、搞服务器、调脚本时踩过的坑和积累的心得。有些东西当时懂了，过几个月又会忘，记下来，既是给未来的自己备忘，也是顺便给有需要的朋友指个路。</p> </li> <li> <p><b>分享干货</b>：把手里收集、整理、验证过的优质资源和实用工具分享出来。</p> </li> </ul> <p>互联网变化太快，曾经热闹的论坛一个个沉寂，大家似乎都习惯了在社交平台刷过即忘的快餐信息。但对于我来说，拥有一个独立的博客，哪怕只是记录一点微小的技术碎片，依然是一件极具仪式感的事。</p> <p>这次不求轰轰烈烈，只求细水长流。</p>]]></content:encoded>
</item></channel></rss>