创建论坛数据分表
作者:cmscn 日期:2008-12-27
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
评论: 0 | 引用: 0 | 查看次数: 557
发表评论