Andy's Blog » » Discuz6&5.5存储过程

Discuz6&5.5存储过程

Discuz6&5.5存储过程

1.解决了中文字符导致失败的问题
2.解决了插入后没有点击率的问题
3.解决了插入后不计入今日主题的问题

CREATE PROCEDURE `AddTopics`($fid smallint, $author char(15) character set gbk, $subject char(80)  character set gbk, $message mediumtext  character set gbk)
BEGIN

    declare $cnt int(11);
   declare $views int(11);
  DECLARE $authorid mediumint;

select   floor((200-0+1)*rand()+100) into $views;
  select count(*) from myDB_threads where fid=$fid and subject=$subject into $cnt;
  IF $cnt<1 THEN
    SELECT uid INTO $authorid FROM myDB_members WHERE username = $author;
    INSERT INTO myDB_threads (fid, subject, author, authorid, dateline, lastpost,views) VALUES ($fid, $subject, $author, $authorid, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(),$views);
    UPDATE myDB_forums SET threads = threads + 1,todayposts=todayposts+1,lastpost=$subject  WHERE fid = $fid;
    INSERT INTO myDB_posts (fid, tid, subject, author, authorid, message, dateline) VALUES ($fid, last_insert_id(), $subject, $author, $authorid, $message, UNIX_TIMESTAMP());
    UPDATE myDB_forums SET posts = posts + 1 WHERE fid = $fid;

  END IF;

END

Incoming search terms:

Tags: mysql, Discuz, 采集, 存储过程

本文地址: http://www.21andy.com/new/20080126/798.html

1 评论 to “PHP开源CMS之MODx”

  1. raymond 于 2008-02-29 18:09:57 发表:

    这个东西怎么用?