我需要的是在一个论坛中向所有新线程添加默认前缀。
我试图在php admin中创建触发器
这是代码:
CREATE TRIGGER set_thread_prefix BEFORE INSERT ON mybb_threads
FOR EACH ROW SET NEW.prefix=46
1142-表'mybb_threads'的用户'xxx'@'localhost'的TRIGGER命令被拒绝
该论坛在altervista托管。
最佳答案
在触发器上应如下图所示。您有else if
但在mysql中它的elseif
之间没有空格
delimiter //
create trigger set_thread_prefix before insert on mybb_threads
for each row
begin
if new.fid = 46 then
set new.prefix = 2;
elseif new.fid = 49 then
set new.prefix = 3;
elseif new.fid = 54 then
set new.prefix = 4;
end if;
end ;//
delimiter ;
关于mysql - mybb如何为某些论坛设置默认前缀,将触发器添加到mybb_threads表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27267877/