wordpress数据库操作备查20120715
wordpress数据库操作备查20120715

wordpress数据库操作备查20120715

  • 目标:更新picasaweb图片的引用url,把所有'http://lh'开头的url修改为'https://lh'开头

    update wp_posts set post_content=replace(post_content,'http://lh','https://lh');

  • 目标:上次合并删除了冗余的帖子,其中的回复也一并删了,把删除的回复整合到现在的帖子中
    1. 搜索所有已删除的帖子(回收站只保留了需要操作的文章4篇)

      select id from wp_posts where post_status='trash';
      +------+
      | id |
      +------+
      | 5676 |
      | 5677 |
      | 5679 |
      | 5680 |
      +------+
      4 rows in set (0.00 sec)

    2. 把四篇删除帖子的回复链接到整合帖子中,新帖id为2634
      可以与第一步合并操作,分开操作比较谨慎

      update wp_comments set comment_post_ID=2634 where comment_post_ID in (5676,5677,5679,5680);

      结果显示4条记录被操作,表明删除的4篇帖子中共有4条留言被移动到新帖中。

    3. 修改新帖留言条数,即目前留言数增加4条

      update wp_posts set comment_count=comment_count+4 where ID=2634;

    4. 此时依然不能显示移动过来的留言,因为目前留言的状态也是被删除,需要直接修改留言状态
      删除的留言中也不能显示,因删除留言的总数未更改
      删除的留言只有要更改的4条,故不要过滤已删除留言的选择条件

      update wp_comments set comment_approved='1' where comment_approved='post-trashed';

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.