discuz 3x 通过 SQL 插入帖子内容(采集开发)

其中需要变更的表有(pre 为表前缀,根据实际替换):

  • pre_forum_thread
  • pre_forum_post_tableid
  • pre_forum_post
  • pre_forum_forum
  • pre_forum_newthread
        START TRANSACTION;

        SET @views = 1;
        SET @_status = 32;
        SET @maxposition = 1;
        SET @premsg = '';
        SET @useip = '127.0.0.1';
        SET @_port = 36790;
        SET @usesig = 1;
        SET @position = 1;
        SET @_first = 1;
        SET @now_timestamp = UNIX_TIMESTAMP();

		# 版块 ID
        SET @fid = 3;
        # 作者 ID
        SET @author_id = 1;
        # 作者名称
        SET @author_name = 'admin';
        # 帖子标题
        SET @title = '我是帖子标题';
        # 帖子内容
        SET @message = '我是帖子内容';

        INSERT INTO `pre_forum_thread`
        (fid, author, authorid, `subject`, dateline, lastpost, lastposter, views, status, maxposition)
        VALUES
        (@fid, @author_name, @author_id, @title, @now_timestamp, @now_timestamp, @author_name, @views, @_status, @maxposition);

        SET @new_thread_id = LAST_INSERT_ID();

        INSERT INTO `pre_forum_post_tableid` (`pid`) VALUES (null);

        SET @new_pid = LAST_INSERT_ID();

        INSERT INTO `pre_forum_post`
        (pid, fid, tid, `first`, author, authorid, `subject`, dateline, premsg, message, useip, `port`, usesig, position, htmlon, bbcodeoff, smileyoff)
        VALUES
        (@new_pid, @fid, @new_thread_id, @_first, @author_name, @author_id, @title, @now_timestamp, @premsg, @message, @useip, @_port, @usesig, @position, 1, -1, -1);

        UPDATE `pre_forum_forum` 
        SET threads=threads+1, posts=posts+1, lastpost=CONCAT(@new_thread_id, "\t", @title, "\t", UNIX_TIMESTAMP(), "\t", @author_name)
        WHERE fid=@fid;

        INSERT INTO `pre_forum_newthread` (`tid`, `fid`, `dateline`) VALUES (@new_thread_id, @fid, UNIX_TIMESTAMP());

        COMMIT;

参考

  • https://www.cnblogs.com/it-tsz/p/14270202.html
  • https://blog.csdn.net/weixin_36225424/article/details/113342677
  • https://blog.csdn.net/weixin_30946627/article/details/115954858
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈挨踢

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值