gpt4 book ai didi

php - #1136 - 列数与第 1 行的值数不匹配,但查询写得很好

转载 作者:行者123 更新时间:2023-11-30 22:39:43 25 4
gpt4 key购买 nike

我正在尝试运行此查询,但它一直给我这个错误,这就是表格。

    CREATE TABLE IF NOT EXISTS `mdl_badge_issued` (
`id` bigint(10) NOT NULL AUTO_INCREMENT,
`badgeid` bigint(10) NOT NULL DEFAULT '0',
`userid` bigint(10) NOT NULL DEFAULT '0',
`uniquehash` longtext NOT NULL,
`dateissued` bigint(10) NOT NULL DEFAULT '0',
`dateexpire` bigint(10) DEFAULT NULL,
`visible` tinyint(1) NOT NULL DEFAULT '0',
`issuernotified` bigint(10) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `mdl_badgissu_baduse_uix` (`badgeid`,`userid`),
KEY `mdl_badgissu_bad_ix` (`badgeid`),
KEY `mdl_badgissu_use_ix` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Defines issued badges' AUTO_INCREMENT=14 ;

这是我要运行的插入内容。

INSERT INTO `mdl_badge_issued` (`badgeid`, `userid`, `uniquehash`, 
`dateissued`, `dateexpire`, `visible`,
`issuernotified`)
VALUES ('47', '941', 'e6c997d04x844g59d3f9e00694e266a9c2ec7a68',
'1436967929', NULL, '1',
NULL);

我一直在尝试通过 phpmyadmin 和 php 脚本执行此操作,但它一直向我提示该错误。

模组:

我忘了说明我有这个表的触发器,有点长。

   DELIMITER //

CREATE TRIGGER certificate_enrol AFTER INSERT ON mdl_badge_issued

FOR EACH ROW

BEGIN
DECLARE user INT;
DECLARE profile_data VARCHAR(100);
DECLARE today INT;

DECLARE contextID INT;
SET user = NEW.userid;
SELECT UNIX_TIMESTAMP(NOW()) INTO today;

SELECT userp.data INTO profile_data FROM mdl_user AS user2 JOIN mdl_user_info_data AS userp ON user2.id = userp.userid WHERE userp.fieldid = 4 AND user2.id = user;

IF profile_data LIKE 'Distribuidor%' AND NEW.badgeid = 44 THEN
SELECT id INTO contextID from mdl_context where instanceid = 88 AND contextlevel = 50;
INSERT INTO mdl_user_enrolments(enrolid,userid,modifierid,timestart,timeend,timecreated,timemodified) VALUES(344,user,1,today,0,today,today) on DUPLICATE KEY UPDATE enrolid=344, userid=user, modifierid=1, timestart=today, timeend=0, timemodified=today;

INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid) VALUES(5,contextID,user,today,1,today,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;

ELSEIF profile_data LIKE 'Distribuidor%' AND NEW.badgeid = 45 THEN
SELECT id INTO contextID from mdl_context where instanceid = 90 AND contextlevel = 50;
INSERT INTO mdl_user_enrolments(enrolid,userid,modifierid,timestart,timeend,timecreated,timemodified) VALUES(350,user,1,today,0,today,today) on DUPLICATE KEY UPDATE enrolid=350, userid=user, modifierid=1, timestart=today, timeend=0, timemodified=today;

INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid) VALUES(5,contextID,user,today,1,today,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;

ELSEIF profile_data LIKE 'Distribuidor%' AND NEW.badgeid = 47 THEN
SELECT id INTO contextID from mdl_context where instanceid = 92 AND contextlevel = 50;
INSERT INTO mdl_user_enrolments(enrolid,userid,modifierid,timestart,timeend,timecreated,timemodified) VALUES(356,user,1,today,0,today,today) on DUPLICATE KEY UPDATE enrolid=356, userid=user, modifierid=1, timestart=today, timeend=0, timemodified=today;

INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid) VALUES(5,contextID,user,today,1,today,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;



ELSEIF profile_data LIKE 'Usuario%' AND NEW.badgeid = 22 THEN
SELECT id INTO contextID from mdl_context where instanceid = 89 AND contextlevel = 50;
INSERT INTO mdl_user_enrolments(enrolid,userid,modifierid,timestart,timeend,timecreated,timemodified) VALUES(347,user,1,today,0,today,today) on DUPLICATE KEY UPDATE enrolid=347, userid=user, modifierid=1, timestart=today, timeend=0, timemodified=today;

INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid,timecreated) VALUES(5,contextID,user,today,1,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;

ELSEIF profile_data LIKE 'Usuario%' AND NEW.badgeid = 46 THEN
SELECT id INTO contextID from mdl_context where instanceid = 91 AND contextlevel = 50;
INSERT INTO mdl_user_enrolments(enrolid,userid,modifierid,timestart,timeend,timecreated,timemodified) VALUES(353,user,1,today,0,today,today) on DUPLICATE KEY UPDATE enrolid=353, userid=user, modifierid=1, timestart=today, timeend=0, timemodified=today;

INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid,timecreated) VALUES(5,contextID,user,today,1,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;

ELSEIF profile_data LIKE 'Usuario%' AND NEW.badgeid = 48 THEN
SELECT id INTO contextID from mdl_context where instanceid = 93 AND contextlevel = 50;
INSERT INTO mdl_user_enrolments(enrolid,userid,modifierid,timestart,timeend,timecreated,timemodified) VALUES(359,user,1,today,0,today,today) on DUPLICATE KEY UPDATE enrolid=359, userid=user, modifierid=1, timestart=today, timeend=0, timemodified=today;

INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid,timecreated) VALUES(5,contextID,user,today,1,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;

END IF;

END;//

DELIMITER ;

最佳答案

感谢您的评论,我刚刚得到解决方案,涉及此表的触发器不匹配,在 mdl_role_assignments 表上的每个插入中。

  INSERT INTO mdl_role_assignments(roleid,contextid,userid,timemodified,modifierid) VALUES(5,contextID,user,today,1,today,today) on DUPLICATE KEY UPDATE roleid=5, contextid=contextID, userid=user, timemodified=today, modifierid=user;

无论如何,谢谢 Russell,我要查看事件内容。

关于php - #1136 - 列数与第 1 行的值数不匹配,但查询写得很好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31432477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com