创建论坛数据分表


sub forum_apart()
  dim tmpdata,basedata,nowdata,tmpdim,tmpnum,bbs_data_num,tmp_data_name,tmp_data_name_true,Dim_ForumData
  basedata="LPLY_BbsData"
  Dim_ForumData=Split(LPLY.Web_ForumData,"|")
  nowdata=Dim_ForumData(0)
  tmpdata=Dim_ForumData(1)
  call admin_td("论坛数据分表")
  if LPLY.chk() then
    bbs_data_num=LPLY.code_int("bbs_data_num",1)
    tmp_data_name=basedata&bbs_data_num
    if LPLY.DataBaseType=0 then
      on error resume next
      call LPLY.exec("create table "&tmp_data_name,0)
      if err then
        error.clear
        call admin_msg("数据库执行失败,请检查您是否有数据库执行权限!或者数据库里已经有该数据表!",pageurl&"action="&action,1)
        exit sub
      end if
      call LPLY.exec("alter table "&tmp_data_name&" add column id autoincrement",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column forum_id integer",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column reply_id integer",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column userid integer",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column username text(20) null",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column topic text(50) null",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column icon text(5) null",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column word memo",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column tim datetime",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column ip text(30) null",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column sys text(250) null",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column is_topic bit",0)
      call LPLY.exec("alter table "&tmp_data_name&" add column is_shield bit",0)
    Else
     tmp_data_name_true=is_bbs_data(tmp_data_name)
     if int(bbs_data_num)<2 or instr(","&lcase(tmpdata)&",",","&tmp_data_name&",")>0 or not tmp_data_name_true then
      call admin_msg("要创建的新数据表名不符合规则或已存在!",pageurl&"action="&action,1)
      exit sub
     end if
      sql="Create TABLE [dbo].["&tmp_data_name&"] (id int IDENTITY (1, 1) NOT NULL CONSTRAINT PK_"&tmp_data_name&" PRIMARY KEY," & _
        "forum_id int NULL ," & _
        "reply_id int NULL ," & _
        "userid int NULL ," & _
        "username nvarchar(20) NULL ," & _
        "topic nvarchar(50) NULL ," & _
        "icon nvarchar(5) NULL ," & _
        "word ntext NULL ," & _
        "tim datetime NULL ," & _
        "ip nvarchar(30) NULL ," & _
        "sys nvarchar(250) NULL ," & _
        "is_topic bit NULL ," & _
        "is_shield bit NULL)"
       call LPLY.Exec(sql,0)
    End If
    call LPLY.Exec("Update LPLY_Configs Set ForumData='"&tmp_data_name&"|"&tmpdata&","&tmp_data_name&"' Where ID=1",0)
    Call LPLY.Cache_Del("LPLY_info")
    call admin_msg("成功创建了新的数据表:"&tmp_data_name&"!",pageurl&"action="&action,1)
    exit sub
  end if

文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: 557
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 20 字 | UBB代码 关闭 | [img]标签 关闭