利用 myphpadmin 批量替换文章内容

UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`, '<pre class="lang:default decode:true " >', ' ');

如果有语法错误就丢给 AI 去 修正,比如 kimi.ai,这段代码解释如下(来自 AI)


这段 MySQL 代码的作用是更新 wp_posts 表中的 post_content 字段。具体来说,它执行以下操作:

  1. UPDATEwp_posts“:指定要更新的表是 wp_posts
  2. SETpost_content= ...:指定要更新的列是 post_content

  3. REPLACE(post_content, '<pre class="lang:default decode:true " >', ' '):这是一个 REPLACE 函数,它用于在 post_content 字段中查找特定的字符串,并将其替换为另一个字符串。

  • 第一个参数是 post_content,表示在哪个字段中进行查找和替换。
  • 第二个参数 '<pre class="lang:default decode:true " >' 是要查找的字符串。这个字符串看起来像是一个 HTML 标签,具体是一个 <pre> 标签,其中包含一些类属性。
  • 第三个参数 ' ' 是要替换成的字符串,这里是一个空格。

综合来看,这段代码的目的是将 wp_posts 表中所有 post_content 字段里出现的 <pre class="lang:default decode:true " > 字符串替换为一个空格。这通常用于清理或修改内容,比如在文本处理或数据清洗的过程中。