procedure TNormNpc.ActionofDISCUZADD(PlayObject: TPlayObject;QuestActionInfo: pTQuestActionInfo); //insermysql
var
title,content,fieldall,values,stime,fid,fieldall2,values2,table,setvalue: string ;
field :array[0..9] of string;
fieldvalue :array[0..9] of string;
sLine :array[0..9] of string;
dJavaStart,nowtime: TDateTime;
i,n18,n14,tid1,pid1,threads,todayposts:integer;
myQuery1: TUniQuery;
begin
if not Form3.rzchckbx1.Checked then
begin
ScriptActionError(PlayObject, '',QuestActionInfo, 'mysql未开启');
exit;
end;
if (QuestActionInfo.sParam1 ='') or (QuestActionInfo.sParam2 ='') or (QuestActionInfo.sParam3 ='')then
begin
ScriptActionError(PlayObject, '', QuestActionInfo, sSC_DISCUZADD);
Exit;
end;
n18 := QuestActionInfo.nParam1;
if n18 >= 1 then
begin
title := QuestActionInfo.sParam4;
content := QuestActionInfo.sParam5;
dJavaStart := StrtoDateTime('1970-01-01 8:00:00');
nowtime :=Now;
stime:= INTTOSTR(MinutesBetween(nowtime, dJavaStart)*60);
sLine[0]:= 'subject|'+title;
sLine[1]:= 'author|'+QuestActionInfo.sParam2 ;
sLine[2]:= 'authorid|'+inttostr(QuestActionInfo.nParam3) ;
sLine[3]:= 'dateline|'+stime ;
sLine[4]:= 'lastpost|'+stime ;
sLine[5]:= 'fid|'+inttostr(n18) ;
sLine[6]:= 'lastposter|'+QuestActionInfo.sParam2 ;
fieldvalue[0]:= GetValidStr3(sLine[0], field[0], ['/', ',', '|']);
fieldvalue[1]:= GetValidStr3(sLine[1], field[1], ['/', ',', '|']);
fieldvalue[2]:= GetValidStr3(sLine[2], field[2], ['/', ',', '|']);
fieldvalue[3]:= GetValidStr3(sLine[3], field[3], ['/', ',', '|']);
fieldvalue[4]:= GetValidStr3(sLine[4], field[4], ['/', ',', '|']);
fieldvalue[5]:= GetValidStr3(sLine[5], field[5], ['/', ',', '|']);
fieldvalue[6]:= GetValidStr3(sLine[6], field[6], ['/', ',', '|']);
table:='pre_forum_thread';
//DISCUZADD 板块ID 发布者ID 发布者UID 标题 内容
IF NOT Form3.connectmysql(Form3.myConnection) THEN EXIT;
try
myQuery1:=TUniQuery.Create(nil);
myQuery1.Connection:=form3.myConnection;
if (field[0]<>'')and( fieldvalue[0] <>'') then begin
fieldall:= field[0];
values:=''''+fieldvalue[0]+'''';
end;
for i:=1 to 9 do begin
if (field[i]<>'')and( fieldvalue[i] <>'') then begin
fieldall:= fieldall+','+field[i];
values:= values+','+''''+fieldvalue[i]+'''';
end;
end;
// PlayObject.SysMsg(format('insert into %s %s VALUES %s',[table,fieldall,values]), c_Green, t_Hint);
fieldall:='('+fieldall+')';
values:='('+values+')';
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text := format('insert into %s %s VALUES %s',[table,fieldall,values]);
// PlayObject.SysMsg(SQL.Text, c_Green, t_Hint);
ExecSQL;
end;
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text :='select @@Identity as fid';
open;
if RecordCount >0 then fid := FieldByName('fid').AsString ;
end;
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text :='Select MAX(tid) AS getfield From pre_forum_thread ';
open;
if RecordCount >0 then tid1:= FieldValues['getfield'] ;
// PlayObject.SysMsg(inttostr(tid1), c_Green, t_Hint);
end;
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text :='Select MAX(pid) AS getfield From pre_forum_post_tableid ';
open;
if RecordCount >0 then pid1:= FieldValues['getfield'] ;
// PlayObject.SysMsg(inttostr(pid1), c_Green, t_Hint);
end;
pid1:=pid1+1;
fieldvalue[0]:='';
field[0]:='';
sLine[0]:= 'pid|'+INTTOSTR(pid1);
fieldvalue[0]:= GetValidStr3(sLine[0], field[0], ['/', ',', '|']);
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text :=format('insert INTO pre_forum_post_tableid (%s) VALUES (%s)',[field[0],fieldvalue[0]]);
ExecSQL;
end;
for i:=0 to 9 do fieldvalue[i]:='';
for i:=0 to 9 do field[i]:='';
sLine[0]:= 'pid|'+INTTOSTR(pid1);
sLine[1]:= 'tid|'+INTTOSTR(tid1) ;
sLine[2]:= 'fid|'+INTTOSTR(n18) ;
sLine[3]:= 'subject|'+title ;
sLine[4]:= 'message|'+content ;
sLine[5]:= 'author|'+QuestActionInfo.sParam2 ;
sLine[6]:= 'authorid|'+inttostr(QuestActionInfo.nParam3) ;
sLine[7]:= 'first|1' ;
sLine[8]:= 'dateline|'+stime ;
fieldvalue[0]:= GetValidStr3(sLine[0], field[0], ['/', ',', '|']);
fieldvalue[1]:= GetValidStr3(sLine[1], field[1], ['/', ',', '|']);
fieldvalue[2]:= GetValidStr3(sLine[2], field[2], ['/', ',', '|']);
fieldvalue[3]:= GetValidStr3(sLine[3], field[3], ['/', ',', '|']);
fieldvalue[4]:= GetValidStr3(sLine[4], field[4], ['/', ',', '|']);
fieldvalue[5]:= GetValidStr3(sLine[5], field[5], ['/', ',', '|']);
fieldvalue[6]:= GetValidStr3(sLine[6], field[6], ['/', ',', '|']);
fieldvalue[7]:= GetValidStr3(sLine[7], field[7], ['/', ',', '|']);
fieldvalue[8]:= GetValidStr3(sLine[8], field[8], ['/', ',', '|']);
if (field[0]<>'')and( fieldvalue[0] <>'') then begin
fieldall:= field[0];
values:=''''+fieldvalue[0]+'''';
end;
for i:=1 to 9 do begin
if (field[i]<>'')and( fieldvalue[i] <>'') then begin
fieldall:= fieldall+','+field[i];
values:= values+','+''''+fieldvalue[i]+'''';
end;
end;
table:='pre_forum_post';
fieldall:='('+fieldall+')';
values:='('+values+')';
// PlayObject.SysMsg(format('insert into %s %s VALUES %s',[table,fieldall,values]), c_Green, t_Hint);
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text := format('insert into %s %s VALUES %s',[table,fieldall,values]);
// PlayObject.SysMsg(SQL.Text, c_Green, t_Hint);
ExecSQL;
end;
fieldvalue[0]:='';
field[0]:='';
sLine[0]:= 'fid|'+inttostr(n18);
fieldvalue[0]:= GetValidStr3(sLine[0], field[0], ['/', ',', '|']);
with MyQuery1 do
begin
close;
sql.Clear;
SQL.Text :=format('Select * From pre_forum_forum where %s =%s',[field[0],fieldvalue[0]]);
open;
if RecordCount >0 then begin
threads:= MyQuery1.FieldValues['threads'] ;
todayposts:= MyQuery1.FieldValues['todayposts'] ;
threads:=threads+1;
todayposts:=todayposts+1;
end;
end;
for i:=0 to 9 do fieldvalue[i]:='';
for i:=0 to 9 do field[i]:='';
sLine[0]:= 'lastpost|'+title;
sLine[1]:= 'todayposts|'+INTTOSTR(todayposts) ;
sLine[2]:= 'threads|'+INTTOSTR(threads) ;
sLine[8]:= 'fid|'+INTTOSTR(n18) ;
fieldvalue[0]:= GetValidStr3(sLine[0], field[0], ['/', ',', '|']);
fieldvalue[1]:= GetValidStr3(sLine[1], field[1], ['/', ',', '|']);
fieldvalue[2]:= GetValidStr3(sLine[2], field[2], ['/', ',', '|']);
fieldvalue[8]:= GetValidStr3(sLine[8], field[8], ['/', ',', '|']);
if (field[0]<>'')and( fieldvalue[0] <>'') then begin
setvalue:= field[0]+'='+ ''''+ fieldvalue[0]+'''';
end;
for i:=1 to 6 do begin
if (field[i]<>'')and( fieldvalue[i] <>'') then begin
setvalue:= setvalue+','+ field[i]+'='+ ''''+ fieldvalue[i]+'''';
end;
end;
table:='pre_forum_forum';
fieldall:='('+fieldall+')';
values:='('+values+')';
with MyQuery1 do
begin
close;
// SQL.Text := format('update pre_forum_forum set lastpost=%s threads=%s,todayposts=%s where fid=%s',[title,threads,todayposts,field[0],fieldvalue[0] ]);
SQL.Text := format('update %s set %s where %s=%s',[table,setvalue,field[8],fieldvalue[8]] );
// PlayObject.SysMsg(SQL.Text, c_Green, t_Hint);
ExecSQL;
end;
finally
MyQuery1.Free;
end;
end;
end;
下载声明:
1、本站所有资源、仅供学习交流,不得商业运营资源,不确保资源完整性,图片和资源仅供参考, 不提供任何技术服务。
2、本站资源均有第三方用户自行上传分享推荐,非本站自制,仅供玩家做交流学习之用!切勿用于商业用途!游戏作品版权
归原作者享有,如有版权问题,请附带版权证明至邮件,本平台将应您的要求删除。举报邮箱 :859840003@qq.com
评论